当前位置: 首页>>代码示例>>Python>>正文


Python Path.codes方法代码示例

本文整理汇总了Python中matplotlib.path.Path.codes方法的典型用法代码示例。如果您正苦于以下问题:Python Path.codes方法的具体用法?Python Path.codes怎么用?Python Path.codes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.path.Path的用法示例。


在下文中一共展示了Path.codes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transform_path

# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import codes [as 别名]
        def transform_path(self, path):
            vertices = path.vertices
            # Intelligent interpolation needed
#            ipath = path.interpolated(self._resolution)
            ipath = path
            ipath = path.interpolated(10)
#            ipath = path.interpolated(3050)
            
            verts = self.transform_no_mod(ipath.vertices)
            codes = ipath.codes
#            print verts.shape
#            print 'transforming lon range:', np.min(verts[:, 0]), np.max(verts[:, 0])
#            if np.isnan(np.max(verts[:, 0])):
#                print 'Got nan: ', path, verts
                 
            paths = []
            paths.append(Path(verts, codes))
            
#            # Have any of the points wrapped? If so, pick up the pen, and start from -360
#            if any(ipath.vertices[:, 0] > np.pi):
#                v = ipath.vertices.copy()
#                print 'splitting -:'
#                v[:, 0] -= 2 * np.pi                
#                print v
#                v = self.transform_no_mod(v)
#                paths.append(Path(v))
#                 
#            # Have any of the points wrapped? If so, pick up the pen, and start from +360
#            if any(ipath.vertices[:, 0] < -np.pi):
#                v = ipath.vertices.copy()
#                v[:, 0] += 2 * np.pi
#                print 'splitting +:'
#                v = self.transform_no_mod(v)
#                paths.append(Path(v))
            s_pole = np.deg2rad(np.array([0, -89.9999]))
            if path.contains_point(s_pole):
                print 'POLE ALERT!!!', path 
                path = Path(verts[:-31])
                paths = [path]
            
            if len(paths) == 1:
                path = paths[0]
            else:
                for path in paths:
                    if path.codes is not None:
                        if path.codes[0] == Path.MOVETO and all(path.codes[1:] == Path.LINETO):
                            path.codes = None
                        else:
                            # This is a bit strict... but a condition of make_compound_path
                            raise ValueError('Cannot draw discontiguous polygons.')
#                        print path.codes
                path = Path.make_compound_path(*paths)
                                      
            return path
开发者ID:pelson,项目名称:mpl_mapping_trial,代码行数:56,代码来源:OLD_custom_projection.py


注:本文中的matplotlib.path.Path.codes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。