MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_minimized_rasterized

Function test_minimized_rasterized

lib/matplotlib/tests/test_image.py:840–870  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

838
839
840def test_minimized_rasterized():
841 # This ensures that the rasterized content in the colorbars is
842 # only as thick as the colorbar, and doesn't extend to other parts
843 # of the image. See #5814. While the original bug exists only
844 # in Postscript, the best way to detect it is to generate SVG
845 # and then parse the output to make sure the two colorbar images
846 # are the same size.
847 from xml.etree import ElementTree
848
849 np.random.seed(0)
850 data = np.random.rand(10, 10)
851
852 fig, ax = plt.subplots(1, 2)
853 p1 = ax[0].pcolormesh(data)
854 p2 = ax[1].pcolormesh(data)
855
856 plt.colorbar(p1, ax=ax[0])
857 plt.colorbar(p2, ax=ax[1])
858
859 buff = io.BytesIO()
860 plt.savefig(buff, format='svg')
861
862 buff = io.BytesIO(buff.getvalue())
863 tree = ElementTree.parse(buff)
864 width = None
865 for image in tree.iter('image'):
866 if width is None:
867 width = image['width']
868 else:
869 if image['width'] != width:
870 assert False
871
872
873def test_load_from_url():

Callers

nothing calls this directly

Calls 5

pcolormeshMethod · 0.80
subplotsMethod · 0.45
colorbarMethod · 0.45
savefigMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…