Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,16 @@ def set_paths(self):
def get_datalim(self, transData):
return (self.get_transform() - transData).transform_bbox(self._bbox)

def get_coordinates(self):
"""
Return the vertices of the mesh as an (M+1, N+1, 2) array.

M, N are the number of quadrilaterals in the rows / columns of the
mesh, corresponding to (M+1, N+1) vertices.
The last dimension specifies the components (x, y).
"""
return self._coordinates

@staticmethod
def convert_mesh_to_paths(meshWidth, meshHeight, coordinates):
"""
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,18 @@ def test_quadmesh_deprecated_positional(fig_test, fig_ref):
ax.add_collection(qmesh)


def test_quadmesh_get_coordinates():
x = [0, 1, 2]
y = [2, 4, 6]
z = np.ones(shape=(2, 2))
xx, yy = np.meshgrid(x, y)
coll = plt.pcolormesh(xx, yy, z)

# shape (3, 3, 2)
coords = np.stack([xx.T, yy.T]).T
assert_array_equal(coll.get_coordinates(), coords)


def test_quadmesh_set_array():
x = np.arange(4)
y = np.arange(4)
Expand Down