Skip to content

Commit 890afaf

Browse files
committed
ENH: Add a PolyQuadMesh for 2d meshes as Polygons
This adds a new collection PolyQuadMesh that is a combination of a PolyCollection and QuadMesh, storing all of the coordinate data and arrays through QuadMesh, but drawing each quad individually through the PolyCollection.draw() method. The common mesh attributes and methods are stored in a private mixin class _MeshData that is used for both QuadMesh and PolyQuadMesh. Additionally, this supports RGB(A) arrays for pcolor() calls now. Previously to update a pcolor array you would need to set only the compressed values. This required keeping track of the mask by the user. For consistency with QuadMesh, we should only accept full 2D arrays that include the mask if a user desires. This also allows for the mask to be updated when setting an array.
1 parent 19d93b7 commit 890afaf

File tree

7 files changed

+455
-193
lines changed

7 files changed

+455
-193
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``PolyQuadMesh.set_array()`` with compressed values
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated. Instead, pass the full 2D array of values
4+
including the mask.

doc/missing-references.json

Lines changed: 55 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
"lib/matplotlib/colorbar.py:docstring of matplotlib.colorbar:1"
2424
],
2525
"matplotlib.axes.Axes.patch": [
26-
"doc/tutorials/intermediate/artists.rst:184",
27-
"doc/tutorials/intermediate/artists.rst:423"
26+
"doc/tutorials/artists.rst:177",
27+
"doc/tutorials/artists.rst:405"
2828
],
2929
"matplotlib.axes.Axes.patches": [
30-
"doc/tutorials/intermediate/artists.rst:461"
30+
"doc/tutorials/artists.rst:443"
3131
],
3232
"matplotlib.axes.Axes.transAxes": [
3333
"lib/mpl_toolkits/axes_grid1/anchored_artists.py:docstring of mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows:4"
@@ -38,23 +38,25 @@
3838
"lib/mpl_toolkits/axes_grid1/anchored_artists.py:docstring of mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar:4"
3939
],
4040
"matplotlib.axes.Axes.xaxis": [
41-
"doc/tutorials/intermediate/artists.rst:607"
41+
"doc/tutorials/artists.rst:589",
42+
"doc/users/explain/axes/index.rst:133"
4243
],
4344
"matplotlib.axes.Axes.yaxis": [
44-
"doc/tutorials/intermediate/artists.rst:607"
45+
"doc/tutorials/artists.rst:589",
46+
"doc/users/explain/axes/index.rst:133"
4547
],
4648
"matplotlib.axis.Axis.label": [
47-
"doc/tutorials/intermediate/artists.rst:654"
49+
"doc/tutorials/artists.rst:636"
4850
],
4951
"matplotlib.colors.Colormap.name": [
5052
"lib/matplotlib/cm.py:docstring of matplotlib.cm:10"
5153
],
5254
"matplotlib.figure.Figure.patch": [
53-
"doc/tutorials/intermediate/artists.rst:184",
54-
"doc/tutorials/intermediate/artists.rst:317"
55+
"doc/tutorials/artists.rst:177",
56+
"doc/tutorials/artists.rst:310"
5557
],
5658
"matplotlib.figure.Figure.transFigure": [
57-
"doc/tutorials/intermediate/artists.rst:366"
59+
"doc/tutorials/artists.rst:359"
5860
],
5961
"max": [
6062
"lib/matplotlib/transforms.py:docstring of matplotlib.transforms:1"
@@ -106,6 +108,7 @@
106108
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.boxplot:1",
107109
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.clabel:1",
108110
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.csd:1",
111+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.ecdf:1",
109112
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.errorbar:1",
110113
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.eventplot:1",
111114
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figimage:1",
@@ -130,22 +133,13 @@
130133
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.specgram:1",
131134
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.spy:1",
132135
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.stairs:1",
136+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.stem:1",
133137
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.step:1",
134138
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplot_mosaic:1",
135139
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.thetagrids:1",
136140
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.violinplot:1",
137141
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.vlines:1"
138142
],
139-
"Axes": [
140-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.axes:1",
141-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.colorbar:1",
142-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.delaxes:1",
143-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplot2grid:1",
144-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplot_mosaic:1",
145-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplots:1",
146-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.twinx:1",
147-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.twiny:1"
148-
],
149143
"ColorType": [
150144
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.errorbar:1",
151145
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.eventplot:1",
@@ -166,9 +160,6 @@
166160
"MarkerType": [
167161
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.scatter:1"
168162
],
169-
"SubplotBase": [
170-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplots:1"
171-
],
172163
"_AxesBase": [
173164
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.twinx:1",
174165
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.twiny:1"
@@ -177,13 +168,13 @@
177168
"doc/api/artist_api.rst:202"
178169
],
179170
"matplotlib.backend_bases.FigureCanvas": [
180-
"doc/tutorials/intermediate/artists.rst:32",
181-
"doc/tutorials/intermediate/artists.rst:34",
182-
"doc/tutorials/intermediate/artists.rst:39"
171+
"doc/tutorials/artists.rst:36",
172+
"doc/tutorials/artists.rst:38",
173+
"doc/tutorials/artists.rst:43"
183174
],
184175
"matplotlib.backend_bases.Renderer": [
185-
"doc/tutorials/intermediate/artists.rst:34",
186-
"doc/tutorials/intermediate/artists.rst:39"
176+
"doc/tutorials/artists.rst:38",
177+
"doc/tutorials/artists.rst:43"
187178
],
188179
"matplotlib.backend_bases._Backend": [
189180
"lib/matplotlib/backend_bases.py:docstring of matplotlib.backend_bases:1"
@@ -212,6 +203,11 @@
212203
"doc/api/collections_api.rst:13",
213204
"lib/matplotlib/collections.py:docstring of matplotlib.collections:1"
214205
],
206+
"matplotlib.collections._MeshData": [
207+
"doc/api/artist_api.rst:202",
208+
"doc/api/collections_api.rst:13",
209+
"lib/matplotlib/collections.py:docstring of matplotlib.collections:1"
210+
],
215211
"matplotlib.image._ImageBase": [
216212
"doc/api/artist_api.rst:202",
217213
"lib/matplotlib/image.py:docstring of matplotlib.image:1"
@@ -247,15 +243,12 @@
247243
],
248244
"mpl_toolkits.axes_grid1.axes_size._Base": [
249245
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Add:1",
250-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.AddList:1",
251246
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.AxesX:1",
252247
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.AxesY:1",
253248
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Fixed:1",
254249
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Fraction:1",
255250
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxExtent:1",
256-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Padded:1",
257-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Scaled:1",
258-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.SizeFromFunc:1"
251+
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Scaled:1"
259252
],
260253
"mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes": [
261254
"doc/api/_as_gen/mpl_toolkits.axes_grid1.parasite_axes.rst:30:<autosummary>:1",
@@ -303,37 +296,33 @@
303296
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.phase_spectrum:1",
304297
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.psd:1",
305298
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.specgram:1",
306-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplots:1",
307299
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.xcorr:1",
308300
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.xticks:1",
309301
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.yticks:1"
310302
],
311303
"numpy.uint8": [
312304
"lib/matplotlib/path.py:docstring of matplotlib.path:1"
313-
],
314-
"unittest.case.TestCase": [
315-
"lib/matplotlib/testing/decorators.py:docstring of matplotlib.testing.decorators:1"
316305
]
317306
},
318307
"py:data": {
319308
"matplotlib.axes.Axes.transAxes": [
320-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.legend:240",
321-
"lib/matplotlib/figure.py:docstring of matplotlib.figure.FigureBase.add_axes:18",
322-
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:107",
323-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:249",
324-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:240"
309+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.legend:238",
310+
"lib/matplotlib/figure.py:docstring of matplotlib.figure.FigureBase.add_artist:1",
311+
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:105",
312+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:242",
313+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:238"
325314
]
326315
},
327316
"py:meth": {
328317
"AbstractPathEffect._update_gc": [
329318
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:26",
330319
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:28",
331320
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:35",
332-
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:39",
333-
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:44"
321+
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:40",
322+
"lib/matplotlib/patheffects.py:docstring of matplotlib.patheffects.AbstractPathEffect:41"
334323
],
335324
"IPython.terminal.interactiveshell.TerminalInteractiveShell.inputhook": [
336-
"doc/users/explain/interactive_guide.rst:420"
325+
"doc/users/explain/figure/interactive_guide.rst:420"
337326
],
338327
"_find_tails": [
339328
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.Barbs:5"
@@ -366,26 +355,31 @@
366355
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.Quiver:38",
367356
"lib/mpl_toolkits/mplot3d/art3d.py:docstring of mpl_toolkits.mplot3d.art3d.Path3DCollection:39",
368357
"lib/mpl_toolkits/mplot3d/art3d.py:docstring of mpl_toolkits.mplot3d.art3d.Poly3DCollection:37"
358+
],
359+
"matplotlib.collections._MeshData.set_array": [
360+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.pcolormesh:155",
361+
"lib/matplotlib/collections.py:docstring of matplotlib.collections.AsteriskPolygonCollection:1",
362+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.pcolormesh:155"
369363
]
370364
},
371365
"py:obj": {
372366
"Artist.stale_callback": [
373-
"doc/users/explain/interactive_guide.rst:323"
367+
"doc/users/explain/figure/interactive_guide.rst:323"
374368
],
375369
"Artist.sticky_edges": [
376-
"doc/api/axes_api.rst:353:<autosummary>:1",
370+
"doc/api/axes_api.rst:354:<autosummary>:1",
377371
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.use_sticky_edges:1"
378372
],
379373
"Axes.dataLim": [
380-
"doc/api/axes_api.rst:292:<autosummary>:1",
374+
"doc/api/axes_api.rst:293:<autosummary>:1",
381375
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes._base._AxesBase.update_datalim:1"
382376
],
383377
"AxesBase": [
384-
"doc/api/axes_api.rst:445:<autosummary>:1",
378+
"doc/api/axes_api.rst:446:<autosummary>:1",
385379
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes._base._AxesBase.add_child_axes:1"
386380
],
387381
"Figure.stale_callback": [
388-
"doc/users/explain/interactive_guide.rst:333"
382+
"doc/users/explain/figure/interactive_guide.rst:333"
389383
],
390384
"Glyph": [
391385
"doc/gallery/misc/ftface_props.rst:28"
@@ -397,7 +391,7 @@
397391
"lib/matplotlib/testing/decorators.py:docstring of matplotlib.testing.decorators:1"
398392
],
399393
"Line2D.pick": [
400-
"doc/users/explain/event_handling.rst:567"
394+
"doc/users/explain/figure/event_handling.rst:568"
401395
],
402396
"QuadContourSet.changed()": [
403397
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.contour:147",
@@ -406,7 +400,7 @@
406400
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:147"
407401
],
408402
"Rectangle.contains": [
409-
"doc/users/explain/event_handling.rst:279"
403+
"doc/users/explain/figure/event_handling.rst:280"
410404
],
411405
"Size.from_any": [
412406
"lib/mpl_toolkits/axes_grid1/axes_grid.py:docstring of mpl_toolkits.axes_grid1.axes_grid.ImageGrid:53",
@@ -445,11 +439,11 @@
445439
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.inset_axes:6"
446440
],
447441
"axes.bbox": [
448-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.legend:137",
449-
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:126",
450-
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:4",
451-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:146",
452-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:137"
442+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.legend:136",
443+
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:69",
444+
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:3",
445+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:140",
446+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:136"
453447
],
454448
"can_composite": [
455449
"lib/matplotlib/image.py:docstring of matplotlib.image:5"
@@ -461,11 +455,11 @@
461455
"lib/matplotlib/backends/backend_agg.py:docstring of matplotlib.backends.backend_agg:1"
462456
],
463457
"figure.bbox": [
464-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.legend:137",
465-
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:126",
466-
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:4",
467-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:146",
468-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:137"
458+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.legend:136",
459+
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:69",
460+
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:3",
461+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:140",
462+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:136"
469463
],
470464
"fmt_xdata": [
471465
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes._base._AxesBase.format_xdata:1"
@@ -489,7 +483,7 @@
489483
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.get_ylim:19"
490484
],
491485
"ipykernel.pylab.backend_inline": [
492-
"doc/users/explain/interactive.rst:255"
486+
"doc/users/explain/figure/interactive.rst:264"
493487
],
494488
"kde.covariance_factor": [
495489
"lib/matplotlib/mlab.py:docstring of matplotlib.mlab:40"
@@ -629,9 +623,6 @@
629623
"matplotlib.animation.ImageMagickFileWriter.bin_path": [
630624
"doc/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.rst:27:<autosummary>:1"
631625
],
632-
"matplotlib.animation.ImageMagickFileWriter.delay": [
633-
"lib/matplotlib/animation.py:docstring of matplotlib.animation.ImageMagickFileWriter.input_names:1:<autosummary>:1"
634-
],
635626
"matplotlib.animation.ImageMagickFileWriter.finish": [
636627
"doc/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.rst:27:<autosummary>:1"
637628
],
@@ -647,9 +638,6 @@
647638
"matplotlib.animation.ImageMagickFileWriter.isAvailable": [
648639
"doc/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.rst:27:<autosummary>:1"
649640
],
650-
"matplotlib.animation.ImageMagickFileWriter.output_args": [
651-
"lib/matplotlib/animation.py:docstring of matplotlib.animation.ImageMagickFileWriter.input_names:1:<autosummary>:1"
652-
],
653641
"matplotlib.animation.ImageMagickFileWriter.saving": [
654642
"doc/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.rst:27:<autosummary>:1"
655643
],
@@ -659,9 +647,6 @@
659647
"matplotlib.animation.ImageMagickWriter.bin_path": [
660648
"doc/api/_as_gen/matplotlib.animation.ImageMagickWriter.rst:27:<autosummary>:1"
661649
],
662-
"matplotlib.animation.ImageMagickWriter.delay": [
663-
"lib/matplotlib/animation.py:docstring of matplotlib.animation.ImageMagickWriter.input_names:1:<autosummary>:1"
664-
],
665650
"matplotlib.animation.ImageMagickWriter.finish": [
666651
"doc/api/_as_gen/matplotlib.animation.ImageMagickWriter.rst:27:<autosummary>:1"
667652
],
@@ -674,9 +659,6 @@
674659
"matplotlib.animation.ImageMagickWriter.isAvailable": [
675660
"doc/api/_as_gen/matplotlib.animation.ImageMagickWriter.rst:27:<autosummary>:1"
676661
],
677-
"matplotlib.animation.ImageMagickWriter.output_args": [
678-
"lib/matplotlib/animation.py:docstring of matplotlib.animation.ImageMagickWriter.input_names:1:<autosummary>:1"
679-
],
680662
"matplotlib.animation.ImageMagickWriter.saving": [
681663
"doc/api/_as_gen/matplotlib.animation.ImageMagickWriter.rst:27:<autosummary>:1"
682664
],
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
``PolyQuadMesh`` is a new class for drawing quadrilateral meshes
2+
----------------------------------------------------------------
3+
4+
``plt.pcolor()`` now returns a ``PolyQuadMesh`` class. It is a
5+
mixin incorporating the usefulness of 2D array and mesh coordinates handling,
6+
but still inheriting the draw methods of ``PolyCollection``, which enables
7+
more control over the rendering properties than a normal ``QuadMesh``. This
8+
new class keeps track of the mask for the user and updates the Polygons that
9+
are sent to the renderer appropriately.
10+
11+
.. plot::
12+
13+
arr = np.arange(12).reshape((3, 4))
14+
15+
fig, ax = plt.subplots()
16+
pc = ax.pcolor(arr)
17+
18+
# Mask one element and show that the hatch is also not drawn
19+
# over that region
20+
pc.set_array(np.ma.masked_equal(arr, 5))
21+
pc.set_hatch('//')
22+
23+
plt.show()

0 commit comments

Comments
 (0)