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

Function test_exact_vmin

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

Source from the content-addressed store, hash-verified

1246
1247@mpl.style.context('mpl20')
1248def test_exact_vmin():
1249 cmap = mpl.colormaps["autumn_r"].with_extremes(under="lightgrey")
1250
1251 # make the image exactly 190 pixels wide
1252 fig = plt.figure(figsize=(1.9, 0.1), dpi=100)
1253 ax = fig.add_axes((0, 0, 1, 1))
1254
1255 data = np.array(
1256 [[-1, -1, -1, 0, 0, 0, 0, 43, 79, 95, 66, 1, -1, -1, -1, 0, 0, 0, 34]],
1257 dtype=float,
1258 )
1259
1260 im = ax.imshow(data, aspect="auto", cmap=cmap, vmin=0, vmax=100)
1261 ax.axis("off")
1262 fig.canvas.draw()
1263
1264 # get the RGBA slice from the image
1265 from_image = im.make_image(fig.canvas.renderer)[0][0]
1266 # expand the input to be 190 long and run through norm / cmap
1267 direct_computation = (
1268 im.cmap(im.norm((data * ([[1]] * 10)).T.ravel())) * 255
1269 ).astype(int)
1270
1271 # check than the RBGA values are the same
1272 assert np.all(from_image == direct_computation)
1273
1274
1275@image_comparison(['image_placement'], extensions=['svg', 'pdf'],

Callers

nothing calls this directly

Calls 9

figureMethod · 0.80
add_axesMethod · 0.80
imshowMethod · 0.80
with_extremesMethod · 0.45
axisMethod · 0.45
drawMethod · 0.45
make_imageMethod · 0.45
cmapMethod · 0.45
normMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…