Search code examples
python-3.xcolorspython-xarrayhvplot

Python: Using hvplot.quadmesh for xarray data shows "blended" colors in a plot


I read in a NetCDF file with Xarray and plot it with hvplot.quadmesh.

Any idea why the colors of the plot itself look like blended or shaded while the colorbar is shown with bright colors?

How can I manipulate the plot to be shown in the color bars´ bright colors?

And also the color (and the colorbar) should be arraged to a log distribution but it does not look being applied... Why?

DS.beta_raw.hvplot.quadmesh(cmap="gouldian",
                            clim = (3000, 5000000),  # adds a widget for time  # sets colorbar limits
                            cnorm = ('log'),
                            clabel = ('normalized range corrected signal'),
                            rot = 0,  # degree rotation of ticks
                            width = 850, 
                            height = 600,
                            title = 'title',
                           )

the plot looks like: enter image description here

But I think it is not due a noisy dataset. Following is the same date set without quadmesh. It is good to be seen that the data set is only noisy in the upper center but keeps the color of the color bar in the other regions of the plot without shading it with greys:

DS.beta_raw.hvplot(cmap="gouldian",
                   clim = (3000, 5000000),  # adds a widget for time  # sets colorbar limits
                   cnorm = ('log'),
                   clabel = ('normalized range corrected signal'),
                   rot = 0,  # degree rotation of ticks
                   width = 850, 
                   height = 600,
                   title = 'title',
                   )

The plotting goes much more faster and the resulting plot looks like this:

enter image description here

However this still results in the warning:

WARNING:param.Image02985: Image dimension time is not evenly sampled to relative tolerance of 0.001. Please use the QuadMesh element for irregularly sampled data or set a higher tolerance on hv.config.image_rtol or the rtol parameter in the Image constructor.

Solution

  • Actually I think the reason why the image looks like this is because hv.QuadMesh adds white grid lines by default, vertically and horizontally (see reference page). As a result the overall image looks pale. If you zoom in, I think you will see the white line separating individual pixels.

    Otherwise, the colormapping appears correct.