8000 NormAndColor class · matplotlib/matplotlib@107513a · GitHub
[go: up one dir, main page]

Skip to content

Commit 107513a

Browse files
committed
NormAndColor class
1 parent ec11ea0 commit 107513a

File tree

5 files changed

+394
-135
lines changed

5 files changed

+394
-135
lines changed

lib/matplotlib/artist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ def format_cursor_data(self, data):
13641364
num_colors = [component.N for component in self.cmap]
13651365

13661366
out_str = '['
1367-
for nn, dd, nc in zip(self._norm, data, num_colors):
1367+
for nn, dd, nc in zip(self.nac._norm, data, num_colors):
13681368
if np.ma.getmask(dd):
13691369
out_str += ", "
13701370
else:

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,27 @@ def prepare_data(d, init):
146146
continue
147147
labeled_mappables.append((label, mappable))
148148
mappables = []
149-
cmaps = [(cmap, name) for name, cmap in sorted(cm._colormaps.items())]
150149
for label, mappable in labeled_mappables:
151150
cmap = mappable.get_cmap()
152-
if cmap not in cm._colormaps.values():
151+
if isinstance(cmap, mcolors.Colormap):
152+
cmaps = [(cmap, name) for name, cmap in sorted(cm._colormaps.items())]
153+
cvals = cm._colormaps.values()
154+
elif isinstance(cmap, mcolors.BivarColormap):
155+
cmaps = [(cmap, name) for name, cmap in sorted(cm._bivar_colormaps.items())]
156+
cvals = cm._bivar_colormaps.values()
157+
else: # isinstance(mappable.get_cmap(), mcolors.MultivarColormap):
158+
cmaps = [(cmap, name) for name, cmap
159+
in sorted(cm._multivar_colormaps.items())]
160+
cvals = cm._multivar_colormaps.values()
161+
if cmap not in cvals:
153162
cmaps = [(cmap, cmap.name), *cmaps]
154-
low, high = mappable.get_clim()
163+
low, high = mappable.nac.get_clim()
164+
if len(low) == 1:
165+
low = low[0]
166+
high = high[0]
167+
else:
168+
low = str(low)[1:-1]
169+
high = str(high)[1:-1]
155170
mappabledata = [
156171
('Label', label),
157172
('Colormap', [cmap.name] + cmaps),
@@ -242,6 +257,9 @@ def apply_callback(data):
242257
label, cmap, low, high = mappable_settings
243258
mappable.set_label(label)
244259
mappable.set_cmap(cmap)
260+
if isinstance(low, str):
261+
low = [float(l) for l in low.split(',')]
262+
high = [float(l) for l in high.split(',')]
245263
mappable.set_clim(*sorted([low, high]))
246264

247265
# re-generate legend, if checkbox is checked
@@ -263,7 +281,6 @@ def apply_callback(data):
263281
if getattr(axes, f"get_{name}lim")() != orig_limits[name]:
264282
figure.canvas.toolbar.push_current()
265283
break
266-
267284
_formlayout.fedit(
268285
datalist, title="Figure options", parent=parent,
269286
icon=QtGui.QIcon(

0 commit comments

Comments
 (0)
0