@@ -65,16 +65,19 @@ def __call__(self, s):
65
65
% (self .key , s , list (six .itervalues (self .valid ))))
66
66
67
67
68
- def _listify_validator (scalar_validator ):
68
+ def _listify_validator (scalar_validator , allow_stringlist = False ):
69
69
def f (s ):
70
70
if isinstance (s , six .string_types ):
71
71
try :
72
72
return [scalar_validator (v .strip ()) for v in s .split (',' )
73
73
if v .strip ()]
74
74
except Exception :
75
- # Sometimes, a list of colors might be a single string
76
- # of single-letter colornames. So give that a shot.
77
- return [scalar_validator (v .strip ()) for v in s if v .strip ()]
75
+ if allow_stringlist :
76
+ # Sometimes, a list of colors might be a single string
77
+ # of single-letter colornames. So give that a shot.
78
+ return [scalar_validator (v .strip ()) for v in s if v .strip ()]
79
+ else :
80
+ raise
78
81
elif type (s ) in (list , tuple ):
79
82
return [scalar_validator (v ) for v in s if v ]
80
83
else :
@@ -331,7 +334,7 @@ def deprecate_axes_colorcycle(value):
331
334
return validate_colorlist (value )
332
335
333
336
334
- validate_colorlist = _listify_validator (validate_color )
337
+ validate_colorlist = _listify_validator (validate_color , allow_stringlist = True )
335
338
validate_colorlist .__doc__ = 'return a list of colorspecs'
336
339
337
340
validate_stringlist = _listify_validator (six .text_type )
@@ -583,6 +586,24 @@ def __call__(self, s):
583
586
validate_grid_axis = ValidateInStrings ('axes.grid.axis' , ['x' , 'y' , 'both' ])
584
587
585
588
589
+ def validate_hatch (s ):
590
+ """
591
+ Validate a hatch pattern.
592
+ A hatch pattern string can have any sequence of the following
593
+ characters: ``\\ / | - + * . x o O``.
594
+
595
+ """
596
+ if not isinstance (s , six .text_type ):
597
+ raise ValueError ("Hatch pattern must be a string" )
598
+ unique_chars = set (s )
599
+ unknown = (unique_chars -
600
+ set (['\\ ' , '/' , '|' , '-' , '+' , '*' , '.' , 'x' , 'o' , 'O' ]))
601
+ if unknown :
602
+ raise ValueError ("Unknown hatch symbol(s): %s" % list (unknown ))
603
+ return s
604
+ validate_hatchlist = _listify_validator (validate_hatch )
605
+
606
+
586
607
_prop_validators = {
587
608
'color' : validate_colorlist ,
588
609
'linewidth' : validate_floatlist ,
@@ -598,6 +619,7 @@ def __call__(self, s):
598
619
'markeredgecolor' : validate_colorlist ,
599
620
'alpha' : validate_floatlist ,
600
621
'marker' : validate_stringlist ,
622
+ 'hatch' : validate_hatchlist ,
601
623
}
602
624
_prop_aliases = {
603
625
'c' : 'color' ,
@@ -611,6 +633,7 @@ def __call__(self, s):
611
633
'ms' : 'markersize' ,
612
634
}
613
635
636
+
614
637
def cycler (* args , ** kwargs ):
615
638
"""
616
639
Creates a :class:`cycler.Cycler` object much like :func:`cycler.cycler`,
0 commit comments