18
18
from matplotlib .backends .qt4_compat import QtGui
19
19
from matplotlib import markers
20
20
21
+
21
22
def get_icon (name ):
22
23
import matplotlib
23
24
basedir = osp .join (matplotlib .rcParams ['datapath' ], 'images' )
24
25
return QtGui .QIcon (osp .join (basedir , name ))
25
26
26
- LINESTYLES = {
27
- '-' : 'Solid' ,
27
+ LINESTYLES = {'-' : 'Solid' ,
28
28
'--' : 'Dashed' ,
29
29
'-.' : 'DashDot' ,
30
30
':' : 'Dotted' ,
@@ -34,9 +34,10 @@ def get_icon(name):
34
34
35
35
MARKERS = markers .MarkerStyle .markers
36
36
37
+
37
38
def figure_edit (axes , parent = None ):
38
39
"""Edit matplotlib figure options"""
39
- sep = (None , None ) # separator
40
+ sep = (None , None ) # separator
40
41
41
42
has_curve = len (axes .get_lines ()) > 0
42
43
@@ -53,9 +54,9 @@ def figure_edit(axes, parent=None):
53
54
(None , "<b>Y-Axis</b>" ),
54
55
('Min' , ymin ), ('Max' , ymax ),
55
56
('Label' , axes .get_ylabel ()),
56
- ('Scale' , [axes .get_yscale (), 'linear' , 'log' ])
57
+ ('Scale' , [axes .get_yscale (), 'linear' , 'log' ]),
57
58
sep ,
58
- ('(Re-)Generate automatic legend' , False ) #defaults to False, as it clobbers carefully hand crafted legends /2014-04-22
59
+ ('(Re-)Generate automatic legend' , False ),
59
60
]
60
61
61
62
if has_curve :
@@ -72,8 +73,7 @@ def figure_edit(axes, parent=None):
72
73
curvelabels = sorted (linedict .keys ())
73
74
for label in curvelabels :
74
75
line = linedict [label ]
75
- curvedata = [
76
- ('Label' , label ),
76
+ curvedata = [('Label' , label ),
77
77
sep ,
78
78
(None , '<b>Line</b>' ),
79
79
('Style' , [line .get_linestyle ()] + linestyles ),
@@ -100,7 +100,8 @@ def apply_callback(data):
100
100
general , = data
101
101
102
102
# Set / General
103
- title , xmin , xmax , xlabel , xscale , ymin , ymax , ylabel , yscale , generate_legend = general #/2014-04-22
103
+ title , xmin , xmax , xlabel , xscale , ymin , ymax , ylabel , yscale , \
104
+ generate_legend = general
104
105
axes .set_xscale (xscale )
105
106
axes .set_yscale (yscale )
106
107
axes .set_title (title )
@@ -114,7 +115,8 @@ def apply_callback(data):
114
115
for index , curve in enumerate (curves ):
115
116
line = linedict [curvelabels [index ]]
116
117
label , linestyle , linewidth , color , \
117
- marker , markersize , markerfacecolor , markeredgecolor = curve
118
+ marker , markersize , markerfacecolor , markeredgecolor \
119
+ = curve
118
120
line .set_label (label )
119
121
line .set_linestyle (linestyle )
120
122
line .set_linewidth (linewidth )
@@ -124,12 +126,12 @@ def apply_callback(data):
124
126
line .set_markersize (markersize )
125
127
line .set_markerfacecolor (markerfacecolor )
126
128
line .set_markeredgecolor (markeredgecolor )
127
-
128
- # re-generate legend, if checkbox is checked. Stefan Kraus/tacaswell 2014-04-22
129
+
130
+ # re-generate legend, if checkbox is checked
129
131
if generate_legend :
130
132
if axes .legend_ is not None :
131
133
old_legend = axes .get_legend ()
132
- new_legend = axes .legend (ncol = old_legend ._ncol )
134
+ new_legend = axes .legend (ncol = old_legend ._ncol )
133
135
new_legend .draggable (old_legend ._draggable is not None )
134
136
else :
135
137
new_legend = axes .legend ()
@@ -140,6 +142,7 @@ def apply_callback(data):
140
142
figure .canvas .draw ()
141
143
142
144
data = formlayout .fedit (datalist , title = "Figure options" , parent = parent ,
143
- icon = get_icon ('qt4_editor_options.svg' ), apply = apply_callback )
145
+ icon = get_icon ('qt4_editor_options.svg' ),
146
+ apply = apply_callback )
144
147
if data is not None :
145
148
apply_callback (data )
0 commit comments