4141 ('densely dashdotdotted' , (0 , (3 , 1 , 1 , 1 , 1 , 1 )))]
4242
4343
44- def plot_linestyles (ax , linestyles ):
44+ def plot_linestyles (ax , linestyles , title ):
4545 X , Y = np .linspace (0 , 100 , 10 ), np .zeros (10 )
4646 yticklabels = []
4747
4848 for i , (name , linestyle ) in enumerate (linestyles ):
4949 ax .plot (X , Y + i , linestyle = linestyle , linewidth = 1.5 , color = 'black' )
5050 yticklabels .append (name )
5151
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 )
5459
5560 # For each line style, add a text annotation with a small offset from
5661 # the reference point (0 in Axes coords, y tick value in Data coords).
@@ -64,8 +69,8 @@ def plot_linestyles(ax, linestyles):
6469fig , (ax0 , ax1 ) = plt .subplots (2 , 1 , gridspec_kw = {'height_ratios' : [1 , 3 ]},
6570 figsize = (10 , 8 ))
6671
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' )
6974
7075plt .tight_layout ()
7176plt .show ()
0 commit comments