@@ -889,6 +889,26 @@ def validate_animation_writer_path(p):
889
889
return p
890
890
891
891
892
+ def validate_grid_linestyle (ls ):
893
+ # Named line style, like u'--' or u'solid'
894
+ if isinstance (ls , six .text_type ):
895
+ return ls
896
+ # Sequence of even length of on and off ink in points.
897
+ # Offset is set to None.
898
+ try :
899
+ if len (ls ) % 2 != 0 :
900
+ # Expecting a sequence of even length
901
+ raise ValueError
902
+ return (None , validate_nseq_float ()(ls ))
903
+ except (ValueError , TypeError ):
904
+ # TypeError can be raised by wrong types passed to float()
905
+ # (called inside the instance of validate_nseq_float).
906
+ pass
907
+
908
+ raise ValueError ("'grid.linestyle' must be a string or " +
909
+ "a even-length sequence of floats." )
910
+
911
+
892
912
# a map from key -> value, converter
893
913
defaultParams = {
894
914
'backend' : ['Agg' , validate_backend ], # agg is certainly
@@ -1215,7 +1235,7 @@ def validate_animation_writer_path(p):
1215
1235
'ytick.direction' : ['out' , six .text_type ], # direction of yticks
1216
1236
1217
1237
'grid.color' : ['#b0b0b0' , validate_color ], # grid color
1218
- 'grid.linestyle' : ['-' , six . text_type ], # solid
1238
+ 'grid.linestyle' : ['-' , validate_grid_linestyle ], # solid
1219
1239
'grid.linewidth' : [0.8 , validate_float ], # in points
1220
1240
'grid.alpha' : [1.0 , validate_float ],
1221
1241
0 commit comments