def get_dasharray(obj, i=None):
"""Get an SVG dash array for the given matplotlib linestyle
Parameters
----------
obj : matplotlib object
The matplotlib line or path object, which must have a get_linestyle()
method which returns a valid matplotlib line code
i : integer (optional)
Returns
-------
dasharray : string
The HTML/SVG dasharray code associated with the object.
"""
if obj.__dict__.get('_dashSeq', None) is not None:
return ','.join(map(str, obj._dashSeq))
else:
ls = obj.get_linestyle()
if i is not None:
ls = ls[i]
dasharray = LINESTYLES.get(ls, None)
if dasharray is None:
warnings.warn("dash style '{0}' not understood: "
"defaulting to solid.".format(ls))
dasharray = LINESTYLES['-']
return dasharray
评论列表
文章目录