hvPlot.quadmesh#

hvPlot.quadmesh(x=None, y=None, z=None, colorbar=True, **kwds)[source]#

QuadMesh plot

quadmesh allows you to plot values on an irregular grid by representing each value as a polygon. It is often useful for displaying projected geographic datasets. Note that this method can be slower than image. To reduce the render time or the size of the saved plot, set rasterize=True to aggregate the values to the pixel. When rasterizing geographic plots, it is recommended to set project=True.

Reference: https://hvplot.holoviz.org/ref/api/manual/hvplot.hvPlot.quadmesh.html

Plotting options: https://hvplot.holoviz.org/ref/plotting_options/index.html

Parameters:
xstring, optional

The coordinate variable along the x-axis

ystring, optional

The coordinate variable along the y-axis

zstring, optional

The data variable to plot

colorbar: boolean

Whether to display a colorbar

**kwdsoptional

Additional keywords arguments are documented in Plotting Options. Run hvplot.help('quadmesh') for the full method documentation.

Returns:
holoviews.element.QuadMesh / Panel object

You can print the object to study its composition and run:

import holoviews as hv
hv.help(the_holoviews_object)

to learn more about its parameters and options.

References

Backend-specific styling options#

alpha, cmap, color, fill_alpha, fill_color, hover_alpha, hover_color, hover_fill_alpha, hover_fill_color, hover_line_alpha, hover_line_cap, hover_line_color, hover_line_dash, hover_line_dash_offset, hover_line_join, hover_line_width, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, muted, muted_alpha, muted_color, muted_fill_alpha, muted_fill_color, muted_line_alpha, muted_line_cap, muted_line_color, muted_line_dash, muted_line_dash_offset, muted_line_join, muted_line_width, nonselection_alpha, nonselection_color, nonselection_fill_alpha, nonselection_fill_color, nonselection_line_alpha, nonselection_line_cap, nonselection_line_color, nonselection_line_dash, nonselection_line_dash_offset, nonselection_line_join, nonselection_line_width, selection_alpha, selection_color, selection_fill_alpha, selection_fill_color, selection_line_alpha, selection_line_cap, selection_line_color, selection_line_dash, selection_line_dash_offset, selection_line_join, selection_line_width, visible

alpha, clims, cmap, ec, edgecolor, edgecolors, hatch, linestyles, linewidths, norm, shading, visible

Examples#

Basic quadmesh plot#

We generate a dummy dataset with an irregular grid. colorbar is True by default.

import hvplot.xarray  # noqa
import numpy as np
import xarray as xr

np.random.seed(42)
# Irregular grid
x = np.sort(np.random.uniform(0, 10, size=40))
y = np.sort(np.random.uniform(0, 5, size=30))
X, Y = np.meshgrid(x, y)
data = np.sin(X) * np.cos(Y) * 3
ds = xr.Dataset({"value": (["y", "x"], data)}, coords={"y": y, "x": x})

ds.hvplot.quadmesh(x='x', y='y', cmap='viridis')

Use of groupby#

When the grid has more dimensions, like time in the example below, widgets are automatically created to explore further the dataset. This is equivalent to setting the groupby to the remaining dimension(s).

import hvplot.xarray  # noqa

ds = hvplot.sampledata.air_temperature("xarray").isel(time=[0, 1])

ds.hvplot.quadmesh(
    x="lon", y="lat", z="air", groupby="time",
    frame_width=400, data_aspect=1, dynamic=False,
)

Use of logz#

import hvplot.xarray  # noqa
import numpy as np
import xarray as xr

np.random.seed(42)
x = np.sort(np.random.uniform(0, 10, size=40))
y = np.sort(np.random.uniform(0, 5, size=30))
X, Y = np.meshgrid(x, y)
data = np.exp(np.sin(X) * np.cos(Y) * 3) * 100
ds = xr.Dataset({"value": (["y", "x"], data)}, coords={"y": y, "x": x})

ds.hvplot.quadmesh(logz=True)

Multidimensional coordinates#

You can plot irregular grids defined by multidimensional coordinates.

import hvplot.xarray  # noqa
import numpy as np
import xarray as xr

np.random.seed(42)
lon, lat = np.meshgrid(np.linspace(-20, 20, 5), np.linspace(0, 30, 4))
lon += lat / 10
lat += lon / 10
da = xr.DataArray(
    np.arange(20).reshape(4, 5),
    dims=["y", "x"],
    coords={"lat": (("y", "x"), lat), "lon": (("y", "x"), lon)},
)

da.hvplot.quadmesh(x="lon", y="lat")

Geographic plot#

import cartopy.crs as ccrs
import hvplot.pandas  # noqa

ds = hvplot.sampledata.air_temperature("xarray").isel(time=0)

ds.hvplot.quadmesh(
    x="lon", y="lat", geo=True, coastline=True,
    projection=ccrs.LambertConformal(central_longitude=-95, central_latitude=35)
)

Image vs. Quadmesh#

See the image reference page for more information about the differences between quadmesh and image.

This web page was generated from a Jupyter notebook and not all interactivity will work on this website.