Open Jhsmit opened 1 year ago
Thanks for the report. For now, you can also accomplish clipping by passing vmin=0
and vmax=1
instead of a normalizer (this is not possible in matplotlib, but proplot tries to standardize arguments across different commands, so e.g. any command that accepts cmap
also accepts colormap-related keywords like vmin
, vmax
, levels
, etc.):
import proplot as pplt
import numpy as np
x = np.arange(10)
y = np.random.rand(10)
c = x**2
fig, ax = pplt.subplots()
ax.scatter(x, y, c=c, cmap='viridis', vmin=0, vmax=1)
ax.format(title='proplot')
I see that in matplotlib, if a normalizer is passed with explicitly-set vmin
and vmax
values (i.e., not the default None
values), then matplotlib will not set them automatically. However, proplot always overrides the vmin
and vmax
values. I'll change this so that normalizer vmin
and vmax
are respected.
FYI the behavior is the same for pcolor
/ pcolormesh
, also the passed normalizer is modified:
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 = pplt.subplots()
norm = pplt.Norm("linear", vmin=0, vmax=1)
print(norm.vmin, norm.vmax)
ax.pcolor(xe, ye, arr, cmap="viridis", norm=norm)
print(norm.vmin, norm.vmax)
prints 0.0 1.0 0.0 1000.0
Description
I'm trying to clip colors in a scatter plot using
norm
, but the keyword argument seems to be ignored, unless I pass aDiscreteNorm
Steps to reproduce
Proplot:
Proplot with discrete norm:
Matplotlib:
Proplot version
matplotlib: 3.4.3 proplot: 0.9.5