8000 Backport qt editor improvements by anntzer · Pull Request #6717 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport qt editor improvements #6717

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

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

8000
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sort and uniquify style entries in figure options.
Fixes the first two points of #5341.
  • Loading branch information
anntzer committed Jul 10, 2016
commit 44ce103457bd4df125bdab905144e0afc943c11d
43 changes: 26 additions & 17 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,38 @@ def figure_edit(axes, parent=None):
continue
linedict[label] = line
curves = []
linestyles = list(six.iteritems(LINESTYLES))
drawstyles = list(six.iteritems(DRAWSTYLES))
markers = list(six.iteritems(MARKERS))

def prepare_data(d, init):
"""Prepare entry for FormLayout.
"""
# List items in dict, dropping duplicate values, sorting by values.
kvs = [(k, v) for v, k in
sorted({v: k for k, v in d.items()}.items())]
# Find the unique kept key with the same value as the init value.
canonical_init, = ({k for k, v in d.items() if v == d[init]}.
intersection(k for k, v in kvs))
return [canonical_init] + kvs

curvelabels = sorted(linedict.keys())
for label in curvelabels:
line = linedict[label]
color = rgb2hex(colorConverter.to_rgb(line.get_color()))
ec = rgb2hex(colorConverter.to_rgb(line.get_markeredgecolor()))
fc = rgb2hex(colorConverter.to_rgb(line.get_markerfacecolor()))
curvedata = [('Label', label),
sep,
(None, '<b>Line</b>'),
('Line Style', [line.get_linestyle()] + linestyles),
('Draw Style', [line.get_drawstyle()] + drawstyles),
('Width', line.get_linewidth()),
('Color', color),
sep,
(None, '<b>Marker</b>'),
('Style', [line.get_marker()] + markers),
('Size', line.get_markersize()),
('Facecolor', fc),
('Edgecolor', ec),
]
curvedata = [
('Label', label),
sep,
(None, '<b>Line</b>'),
('Line Style', prepare_data(LINESTYLES, line.get_linestyle())),
('Draw Style', prepare_data(DRAWSTYLES, line.get_drawstyle())),
('Width', line.get_linewidth()),
('Color', color),
sep,
(None, '<b>Marker</b>'),
('Style', prepare_data(MARKERS, line.get_marker())),
('Size', line.get_markersize()),
('Facecolor', fc),
('Edgecolor', ec)]
curves.append([curvedata, label, ""])

# make sure that there is at least one displayed curve
Expand Down
0