Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0edc78b

Browse filesBrowse files
committed
Add test
1 parent c660133 commit 0edc78b
Copy full SHA for 0edc78b

File tree

Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Loading

‎lib/matplotlib/tests/test_colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py
+14Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.