8000 Add test · matplotlib/matplotlib@2950bdb · GitHub
[go: up one dir, main page]

Skip to content

Commit 2950bdb

Browse files
dstansbyjklymak
authored andcommitted
Add test
1 parent 21247cf commit 2950bdb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Loading

lib/matplotlib/tests/test_colorbar.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,3 +570,17 @@ def test_colorbar_label():
570570

571571
cbar3 = fig.colorbar(im, orientation='horizontal', label='horizontal cbar')
572572
assert cbar3.ax.get_xlabel() == 'horizontal cbar'
573+
574+
@image_comparison(
575+
baseline_images=['colorbar_norms'], extensions=['png'])
576+
def test_cbar_norms():
577+
# Test colormaps with different norms
578+
norms = [mcolors.Normalize(vmin=-1, vmax=2),
579+
mcolors.BoundaryNorm(boundaries=[-1, 0, 1], ncolors=4),
580+
mcolors.LogNorm(vmin=1, vmax=1e4),
581+
mcolors.PowerNorm(gamma=0.2, vmin=0.1, vmax=0.6),
582+
mcolors.SymLogNorm(1, vmin=-10, vmax=10),
583+
mcolors.TwoSlopeNorm(1, vmin=0, vmax=2)]
584+
fig, axs = plt.subplots(ncols=len(norms), constrained_layout=True)
585+
for ax, norm in zip(axs, norms):
586+
fig.colorbar(cm.ScalarMappable(norm=norm, cmap='viridis'), cax=ax, extend='both')

0 commit comments

Comments
 (0)
0