本文整理汇总了Python中matplotlib.cbook.ls_mapper方法的典型用法代码示例。如果您正苦于以下问题:Python cbook.ls_mapper方法的具体用法?Python cbook.ls_mapper怎么用?Python cbook.ls_mapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.cbook
的用法示例。
在下文中一共展示了cbook.ls_mapper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_linestyle
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import ls_mapper [as 别名]
def set_linestyle(self, ls):
"""
Set the linestyle(s) for the collection.
ACCEPTS: ['solid' | 'dashed', 'dashdot', 'dotted' |
(offset, on-off-dash-seq) ]
"""
try:
dashd = backend_bases.GraphicsContextBase.dashd
if cbook.is_string_like(ls):
if ls in dashd:
dashes = [dashd[ls]]
elif ls in cbook.ls_mapper:
dashes = [dashd[cbook.ls_mapper[ls]]]
else:
raise ValueError()
elif cbook.iterable(ls):
try:
dashes = []
for x in ls:
if cbook.is_string_like(x):
if x in dashd:
dashes.append(dashd[x])
elif x in cbook.ls_mapper:
dashes.append(dashd[cbook.ls_mapper[x]])
else:
raise ValueError()
elif cbook.iterable(x) and len(x) == 2:
dashes.append(x)
else:
raise ValueError()
except ValueError:
if len(ls) == 2:
dashes = ls
else:
raise ValueError()
else:
raise ValueError()
except ValueError:
raise ValueError('Do not know how to convert %s to dashes' % ls)
self._linestyles = dashes
示例2: validate_webagg_address
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import ls_mapper [as 别名]
def validate_webagg_address(s):
if s is not None:
import socket
try:
socket.inet_aton(s)
except socket.error as e:
raise ValueError("'webagg.address' is not a valid IP address")
return s
raise ValueError("'webagg.address' is not a valid IP address")
# A validator dedicated to the named line styles, based on the items in
# ls_mapper, and a list of possible strings read from Line2D.set_linestyle