Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0dc4e43

Browse files
committed
Don't crash qt figure options on unknown marker styles.
Currently, if a plot uses a "custom" marker style (e.g., a mathtext string, `plt.plot([1, 2], ls="none", marker="$1/2$")`, or a n-gon, `marker=(7, 0)`), trying to open the qt figure options editor will crash the process because of an unhandled KeyError in `prepare_data` (at `canonical_init = name2short[d[init]]`). Instead, create an entry on-the-fly for that custom style.
1 parent 1652ed1 commit 0dc4e43

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def prepare_data(d, init):
9393
FormLayout combobox, namely `[initial_name, (shorthand,
9494
style_name), (shorthand, style_name), ...]`.
9595
"""
96+
if init not in d:
97+
d = {**d, init: str(init)}
9698
# Drop duplicate shorthands from dict (by overwriting them during
9799
# the dict comprehension).
98100
name2short = {name: short for short, name in d.items()}

0 commit comments

Comments
 (0)