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


Python Polygon.set_clip_box方法代码示例

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


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

示例1: plotReachSet_norm1

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_clip_box [as 别名]
 def plotReachSet_norm1(self, NUM, figname):
     fig = p.figure()
     for j in range(n):
         ax = fig.add_subplot(2,2,j+1 , aspect='equal')
         ax.set_xlim(0, 4)
         ax.set_ylim(0, 1)
         ax.set_xlabel('$x_'+str(j+1)+'$')
         ax.set_ylabel('$y_'+str(j+1)+'$')
         for trace in self:
             for i in [int(floor(k*len(trace.T)/NUM)) for k in range(NUM)]:
                 verts = [(trace.x[i][j] + 1/trace.d_norm1[i][2*j], trace.y[i][j]                          ),
                          (trace.x[i][j]                            , trace.y[i][j] - 1/trace.d_norm1[i][2*j+1]),
                          (trace.x[i][j] - 1/trace.d_norm1[i][2*j], trace.y[i][j]                          ),
                          (trace.x[i][j]                              , trace.y[i][j] + 1/trace.d_norm1[i][2*j+1])]
                 # poly = Ellipse((trace.x[i][j],trace.y[i][j]), width=trace.d1[i], height=trace.d2[i], angle=trace.theta[i])
                 poly = Polygon(verts, facecolor='0.8', edgecolor='k')
                 ax.add_artist(poly)
                 poly.set_clip_box(ax.bbox)
                 poly.set_alpha(1)
                 if i==0:
                     poly.set_facecolor('r')
                 else:
                     poly.set_facecolor(p.rand(3))
         #for trace in self:
             #e = Ellipse((trace.x[0][j],trace.y[0][j]), width=trace.d1[0], height=trace.d2[0], angle=trace.theta[0])
             #ax.add_artist(e)
             #e.set_clip_box(ax.bbox)
             #e.set_alpha(1)
             #e.set_facecolor('r')
 #e.set_edgecolor('r')
     p.savefig(figname)
开发者ID:maidens,项目名称:Matrix-Measure-Reachability-Project,代码行数:33,代码来源:Figure5.py

示例2: plot_category_chart

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_clip_box [as 别名]
def plot_category_chart(ax, res, show_legend=True):
    """Plot stacked bar chart of remapping response categories
    
    Arguments:
    ax -- axis to plot into
    res -- trends results dictionary
    
    Keyword arguments:
    show_legend -- whether to draw legend
    """
    from matplotlib.patches import Polygon
    labels = res['mismatch_labels']
    N = res['N_mismatch']
    x = np.arange(1, N+1)
    
    stacked = np.empty((len(CL_LABELS)+1, N), 'd')
    stacked[0] = 0.0
    stacked[-1] = 1.0
    cats = res['categories']
    for i in xrange(1,len(CL_LABELS)):
        stacked[i] = stacked[i-1] + cats[CL_LABELS[i-1]]
    poly_kwargs = dict(aa=True, lw=1.5, alpha=0.85)
    xloop = np.concatenate((x, x[::-1]))
    for i in xrange(len(CL_LABELS)):
        yloop = np.concatenate((stacked[i], stacked[i+1,::-1]))
        p = Polygon(np.c_[xloop, yloop], fc=CL_COLORS[i], 
            ec=CL_COLORS[i], label=CL_LABELS[i], **poly_kwargs)
        ax.add_artist(p)
        p.set_clip_box(ax.bbox)
    ax.axis([1, N, 0, 1])
    ax.set_xticks(x)
    ax.set_xticklabels(labels)
    ax.set_xlabel('Mismatch')
    ax.set_ylabel('Response Fraction')
    if show_legend:
        ax.legend(loc='upper left', bbox_to_anchor=(1.01, 1.0))
    return ax
开发者ID:jdmonaco,项目名称:vmo-feedback-model,代码行数:39,代码来源:trends.py


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