Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 061061b

Browse files
committed
extend 'grid.linestyle' valid types to on-off ink sequences
1 parent c15694b commit 061061b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,26 @@ def validate_animation_writer_path(p):
889889
return p
890890

891891

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+
892912
# a map from key -> value, converter
893913
defaultParams = {
894914
'backend': ['Agg', validate_backend], # agg is certainly
@@ -1215,7 +1235,7 @@ def validate_animation_writer_path(p):
12151235
'ytick.direction': ['out', six.text_type], # direction of yticks
12161236

12171237
'grid.color': ['#b0b0b0', validate_color], # grid color
1218-
'grid.linestyle': ['-', six.text_type], # solid
1238+
'grid.linestyle': ['-', validate_grid_linestyle], # solid
12191239
'grid.linewidth': [0.8, validate_float], # in points
12201240
'grid.alpha': [1.0, validate_float],
12211241

0 commit comments

Comments
 (0)