當前位置: 首頁>>代碼示例>>Python>>正文


Python cbook.ls_mapper方法代碼示例

本文整理匯總了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 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:43,代碼來源:collections.py

示例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 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:14,代碼來源:rcsetup.py


注:本文中的matplotlib.cbook.ls_mapper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。