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

Function test_proportional_colorbars

lib/matplotlib/tests/test_colorbar.py:953–976  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

951@image_comparison(['proportional_colorbars.png'], remove_text=True,
952 style='mpl20')
953def test_proportional_colorbars():
954
955 x = y = np.arange(-3.0, 3.01, 0.025)
956 X, Y = np.meshgrid(x, y)
957 Z1 = np.exp(-X**2 - Y**2)
958 Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
959 Z = (Z1 - Z2) * 2
960
961 levels = [-1.25, -0.5, -0.125, 0.125, 0.5, 1.25]
962 cmap = mcolors.ListedColormap(
963 ['0.3', '0.5', 'white', 'lightblue', 'steelblue'],
964 under='darkred',
965 over='crimson',
966 )
967 norm = mcolors.BoundaryNorm(levels, cmap.N)
968
969 extends = ['neither', 'both']
970 spacings = ['uniform', 'proportional']
971 fig, axs = plt.subplots(2, 2)
972 for i in range(2):
973 for j in range(2):
974 CS3 = axs[i, j].contourf(X, Y, Z, levels, cmap=cmap, norm=norm,
975 extend=extends[i])
976 fig.colorbar(CS3, spacing=spacings[j], ax=axs[i, j])
977
978
979@image_comparison(['extend_drawedges.png'], remove_text=True, style='mpl20')

Callers

nothing calls this directly

Calls 3

subplotsMethod · 0.45
contourfMethod · 0.45
colorbarMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…