41
41
('densely dashdotdotted' , (0 , (3 , 1 , 1 , 1 , 1 , 1 )))]
42
42
43
43
44
- def plot_linestyles (ax , linestyles ):
44
+ def plot_linestyles (ax , linestyles , title ):
45
45
X , Y = np .linspace (0 , 100 , 10 ), np .zeros (10 )
46
46
yticklabels = []
47
47
48
48
for i , (name , linestyle ) in enumerate (linestyles ):
49
49
ax .plot (X , Y + i , linestyle = linestyle , linewidth = 1.5 , color = 'black' )
50
50
yticklabels .append (name )
51
51
52
- ax .set (xticks = [], ylim = (- 0.5 , len (linestyles )- 0.5 ),
53
- yticks = np .arange (len (linestyles )), yticklabels = yticklabels )
52
+ ax .set_title (title )
53
+ ax .set (ylim = (- 0.5 , len (linestyles )- 0.5 ),
54
+ yticks = np .arange (len (linestyles )),
55
+ yticklabels = yticklabels )
56
+ ax .tick_params (left = False , bottom = False , labelbottom = False )
57
+ for spine in ax .spines .values ():
58
+ spine .set_visible (False )
54
59
55
60
# For each line style, add a text annotation with a small offset from
56
61
# the reference point (0 in Axes coords, y tick value in Data coords).
@@ -64,8 +69,8 @@ def plot_linestyles(ax, linestyles):
64
69
fig , (ax0 , ax1 ) = plt .subplots (2 , 1 , gridspec_kw = {'height_ratios' : [1 , 3 ]},
65
70
figsize = (10 , 8 ))
66
71
67
- plot_linestyles (ax0 , linestyle_str [::- 1 ])
68
- plot_linestyles (ax1 , linestyle_tuple [::- 1 ])
72
+ plot_linestyles (ax0 , linestyle_str [::- 1 ], title = 'Named linestyles' )
73
+ plot_linestyles (ax1 , linestyle_tuple [::- 1 ], title = 'Parametrized linestyles' )
69
74
70
75
plt .tight_layout ()
71
76
plt .show ()
0 commit comments