Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ultraplot/axes/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,9 @@ def _parse_cmap(
cmap_kw = cmap_kw or {}
norm_kw = norm_kw or {}
# If norm is given we use it to set vmin and vmax
if (vmin is not None or vmax is not None) and norm is not None:
print(vmin, vmax, norm)
Comment thread
beckermr marked this conversation as resolved.
Outdated
raise ValueError("If 'norm' is given, 'vmin' and 'vmax' must not be set.")
if isinstance(norm, mcolors.Normalize):
vmin = norm.vmin
vmax = norm.vmax
Expand Down
9 changes: 5 additions & 4 deletions ultraplot/tests/test_1dplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def test_triplot_variants(x, y, z, triangles, use_triangulation, use_datadict):
return fig


@pytest.mark.mpl_image_compare
def test_norm_not_modified():
"""
Ensure that norm is correctly passed to pcolor and related functions.
Expand All @@ -443,17 +444,17 @@ def test_norm_not_modified():
c = y
cmap = uplt.Colormap("viridis")
norm = uplt.Norm("linear", 0, 10)
fig, ax = uplt.subplots()
ax.scatter(x, y, c=c, cmap=cmap, norm=norm)
fig, (left, right) = uplt.subplots(ncols=2, share=0)
left.scatter(x, y, c=c, cmap=cmap, norm=norm)
assert norm.vmin == 0
assert norm.vmax == 10

arr = np.random.rand(20, 40) * 1000
xe = np.linspace(0, 1, num=40, endpoint=True)
ye = np.linspace(0, 1, num=20, endpoint=True)

fig, ax = uplt.subplots()
norm = uplt.Norm("linear", vmin=0, vmax=1)
ax.pcolor(xe, ye, arr, cmap="viridis", norm=norm)
right.pcolor(xe, ye, arr, cmap="viridis", norm=norm)
assert norm.vmin == 0
assert norm.vmax == 1
return fig