-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Include scatter plots in Qt figure options editor. #12779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,39 +137,43 @@ def prepare_data(d, init): | |
# Is there a curve displayed? | ||
has_curve = bool(curves) | ||
|
||
# Get / Images | ||
imagedict = {} | ||
for image in axes.get_images(): | ||
label = image.get_label() | ||
if label == '_nolegend_': | ||
# Get ScalarMappables. | ||
mappabledict = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would probably do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's also curvedict/curvedata/etc. for Line2D instances (just above), so if you want to get to change both of them... |
||
for mappable in [*axes.images, *axes.collections]: | ||
label = mappable.get_label() | ||
if label == '_nolegend_' or mappable.get_array() is None: | ||
continue | ||
imagedict[label] = image | ||
imagelabels = sorted(imagedict, key=cmp_key) | ||
images = [] | ||
mappabledict[label] = mappable | ||
mappablelabels = sorted(mappabledict, key=cmp_key) | ||
mappables = [] | ||
cmaps = [(cmap, name) for name, cmap in sorted(cm.cmap_d.items())] | ||
for label in imagelabels: | ||
image = imagedict[label] | ||
cmap = image.get_cmap() | ||
for label in mappablelabels: | ||
mappable = mappabledict[label] | ||
cmap = mappable.get_cmap() | ||
if cmap not in cm.cmap_d.values(): | ||
cmaps = [(cmap, cmap.name)] + cmaps | ||
low, high = image.get_clim() | ||
imagedata = [ | ||
cmaps = [(cmap, cmap.name), *cmaps] | ||
low, high = mappable.get_clim() | ||
mappabledata = [ | ||
('Label', label), | ||
('Colormap', [cmap.name] + cmaps), | ||
('Min. value', low), | ||
('Max. value', high), | ||
('Interpolation', | ||
[image.get_interpolation()] | ||
+ [(name, name) for name in sorted(mimage.interpolations_names)])] | ||
images.append([imagedata, label, ""]) | ||
# Is there an image displayed? | ||
has_image = bool(images) | ||
] | ||
if hasattr(mappable, "get_interpolation"): # Images. | ||
interpolations = [ | ||
(name, name) for name in sorted(mimage.interpolations_names)] | ||
mappabledata.append(( | ||
'Interpolation', | ||
[mappable.get_interpolation(), *interpolations])) | ||
mappables.append([mappabledata, label, ""]) | ||
# Is there a scalarmappable displayed? | ||
has_sm = bool(mappables) | ||
|
||
datalist = [(general, "Axes", "")] | ||
if curves: | ||
datalist.append((curves, "Curves", "")) | ||
if images: | ||
datalist.append((images, "Images", "")) | ||
if mappables: | ||
datalist.append((mappables, "Images, etc.", "")) | ||
|
||
def apply_callback(data): | ||
"""This function will be called to apply changes""" | ||
|
@@ -178,7 +182,7 @@ def apply_callback(data): | |
|
||
general = data.pop(0) | ||
curves = data.pop(0) if has_curve else [] | ||
images = data.pop(0) if has_image else [] | ||
mappables = data.pop(0) if has_sm else [] | ||
if data: | ||
raise ValueError("Unexpected field") | ||
|
||
|
@@ -223,14 +227,17 @@ def apply_callback(data): | |
line.set_markerfacecolor(markerfacecolor) | ||
line.set_markeredgecolor(markeredgecolor) | ||
|
||
# Set / Images | ||
for index, image_settings in enumerate(images): | ||
image = imagedict[imagelabels[index]] | ||
label, cmap, low, high, interpolation = image_settings | ||
image.set_label(label) | ||
image.set_cmap(cm.get_cmap(cmap)) | ||
image.set_clim(*sorted([low, high])) | ||
image.set_interpolation(interpolation) | ||
# Set ScalarMappables. | ||
for index, mappable_settings in enumerate(mappables): | ||
mappable = mappabledict[mappablelabels[index]] | ||
if len(mappable_settings) == 5: | ||
label, cmap, low, high, interpolation = mappable_settings | ||
mappable.set_interpolation(interpolation) | ||
elif len(mappable_settings) == 4: | ||
label, cmap, low, high = mappable_settings | ||
mappable.set_label(label) | ||
mappable.set_cmap(cm.get_cmap(cmap)) | ||
mappable.set_clim(*sorted([low, high])) | ||
|
||
# re-generate legend, if checkbox is checked | ||
if generate_legend: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor formatting nitpicking. I think we would usually do
# get ScalarMappables
. Same with theset
below.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I capitalize (nearly) all my comments and include final stops (Matplotlib or not)...