A quadrilateral mesh is a grid of M by N adjacent qudrilaterals that are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices :
(m+1, n) ----------- (m+1, n+1) / / / / / / n) -------- (m, n+1)
The mesh need not be regular and the polygons need not be convex.
Unlike other .Collection
\s, the default pickradius of .QuadMesh
is 0, i.e. ~.Artist.contains
checks whether the test point is within any of the mesh quadrilaterals.
There exists a deprecated API version QuadMesh(M, N, coords)
, where the dimensions are given explicitly and coords
is a (M*N, 2) array-like. This has been deprecated in Matplotlib 3.5. The following describes the semantics of this deprecated API.
A quadrilateral mesh consists of a grid of vertices. The dimensions of this array are (meshWidth + 1, meshHeight + 1). Each vertex in the mesh has a different set of "mesh coordinates" representing its position in the topology of the mesh. For any values (m, n) such that 0 <= m <= meshWidth and 0 <= n <= meshHeight, the vertices at mesh coordinates (m, n), (m, n + 1), (m + 1, n + 1), and (m + 1, n) form one of the quadrilaterals in the mesh. There are thus (meshWidth * meshHeight) quadrilaterals in the mesh. The mesh need not be regular and the polygons need not be convex.
A quadrilateral mesh is represented by a (2 x ((meshWidth + 1) * (meshHeight + 1))) numpy array coordinates, where each row is the x and y coordinates of one of the vertices. To define the function that maps from a data point to its corresponding color, use the set_cmap
method. Each of these arrays is indexed in row-major order by the mesh coordinates of the vertex (or the mesh coordinates of the lower left vertex, in the case of the colors).
For example, the first entry in coordinates is the coordinates of the vertex at mesh coordinates (0, 0), then the one at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on.
The vertices. coordinates[m, n]
specifies the (x, y) coordinates of vertex (m, n).
Class for the efficient drawing of a quadrilateral mesh.
The following pages refer to to this document either explicitly or contain code examples using this.
matplotlib.pyplot.hist2d
matplotlib.axes._axes.Axes.hist2d
matplotlib.pyplot.pcolormesh
matplotlib.axes._axes.Axes.pcolorfast
matplotlib.collections.QuadMesh
matplotlib.axes._axes.Axes.pcolormesh
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them