@@ -78,29 +78,36 @@ def figure_edit(axes, parent=None):
78
78
continue
79
79
linedict [label ] = line
80
80
curves = []
81
- linestyles = list (six .iteritems (LINESTYLES ))
82
- drawstyles = list (six .iteritems (DRAWSTYLES ))
83
- markers = list (six .iteritems (MARKERS ))
81
+ def prepare_data (d , init ):
82
+ """Prepare entry for FormLayout.
83
+ """
84
+ # List items in dict, dropping duplicate values, sorting by values.
85
+ kvs = [(k , v ) for v , k in
86
+ sorted ({v : k for k , v in d .items ()}.items ())]
87
+ # Find the unique kept key with the same value as the init value.
88
+ canonical_init , = ({k for k , v in d .items () if v == d [init ]}.
89
+ intersection (k for k , v in kvs ))
90
+ return [canonical_init ] + kvs
84
91
curvelabels = sorted (linedict .keys ())
85
92
for label in curvelabels :
86
93
line = linedict [label ]
87
94
color = rgb2hex (colorConverter .to_rgb (line .get_color ()))
88
95
ec = rgb2hex (colorConverter .to_rgb (line .get_markeredgecolor ()))
89
96
fc = rgb2hex (colorConverter .to_rgb (line .get_markerfacecolor ()))
90
- curvedata = [( 'Label' , label ),
91
- sep ,
92
- ( None , '<b>Line</b>' ) ,
93
- ( ' Line Style' , [ line . get_linestyle ()] + linestyles ),
94
- ( 'Draw Style' , [ line .get_drawstyle ()] + drawstyles ),
95
- ( 'Width ' , line .get_linewidth ( )),
96
- ( 'Color ' , color ),
97
- sep ,
98
- ( None , '<b>Marker</b>' ) ,
99
- ( 'Style' , [ line . get_marker ()] + markers ),
100
- ( 'Size ' , line .get_markersize ( )),
101
- ( 'Facecolor ' , fc ),
102
- ( 'Edgecolor ' , ec ),
103
- ]
97
+ curvedata = [
98
+ ( 'Label' , label ) ,
99
+ sep ,
100
+ ( None , '<b> Line</b>' ),
101
+ ( 'Line Style' , prepare_data ( LINESTYLES , line .get_linestyle ()) ),
102
+ ( 'Draw Style ' , prepare_data ( DRAWSTYLES , line .get_drawstyle () )),
103
+ ( 'Width ' , line . get_linewidth () ),
104
+ ( 'Color' , color ) ,
105
+ sep ,
106
+ ( None , '<b>Marker</b>' ),
107
+ ( 'Style ' , prepare_data ( MARKERS , line .get_marker () )),
108
+ ( 'Size ' , line . get_markersize () ),
109
+ ( 'Facecolor ' , fc ),
110
+ ( 'Edgecolor' , ec ) ]
104
111
curves .append ([curvedata , label , "" ])
105
112
106
113
# make sure that there is at least one displayed curve
0 commit comments