@@ -65,16 +65,19 @@ def __call__(self, s):
6565 % (self .key , s , list (six .itervalues (self .valid ))))
6666
6767
68- def _listify_validator (scalar_validator ):
68+ def _listify_validator (scalar_validator , allow_stringlist = False ):
6969 def f (s ):
7070 if isinstance (s , six .string_types ):
7171 try :
7272 return [scalar_validator (v .strip ()) for v in s .split (',' )
7373 if v .strip ()]
7474 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
7881 elif type (s ) in (list , tuple ):
7982 return [scalar_validator (v ) for v in s if v ]
8083 else :
@@ -331,7 +334,7 @@ def deprecate_axes_colorcycle(value):
331334 return validate_colorlist (value )
332335
333336
334- validate_colorlist = _listify_validator (validate_color )
337+ validate_colorlist = _listify_validator (validate_color , allow_stringlist = True )
335338validate_colorlist .__doc__ = 'return a list of colorspecs'
336339
337340validate_stringlist = _listify_validator (six .text_type )
@@ -583,6 +586,24 @@ def __call__(self, s):
583586validate_grid_axis = ValidateInStrings ('axes.grid.axis' , ['x' , 'y' , 'both' ])
584587
585588
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+
586607_prop_validators = {
587608 'color' : validate_colorlist ,
588609 'linewidth' : validate_floatlist ,
@@ -598,6 +619,7 @@ def __call__(self, s):
598619 'markeredgecolor' : validate_colorlist ,
599620 'alpha' : validate_floatlist ,
600621 'marker' : validate_stringlist ,
622+ 'hatch' : validate_hatchlist ,
601623 }
602624_prop_aliases = {
603625 'c' : 'color' ,
@@ -611,6 +633,7 @@ def __call__(self, s):
611633 'ms' : 'markersize' ,
612634 }
613635
636+
614637def cycler (* args , ** kwargs ):
615638 """
616639 Creates a :class:`cycler.Cycler` object much like :func:`cycler.cycler`,
0 commit comments