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


Python Axes.add_line方法代码示例

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


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

示例1: fibers_2d_yz

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_line [as 别名]
def fibers_2d_yz():
    '''
        Plot fibers in 2D section (plane YZ)
    '''
    fig2 = figure(1)
    ax2 = Axes(fig2, [.1, .1, .8, .8])

    fig2.add_axes(ax2)
    for i in range(0, len(sx[0])):
        l = Line2D([sy[0][i] - fib.lf / 2. * cos(phi_y[0][i]), sy[0][i] + fib.lf / 2. * cos(phi_y[0][i])], \
                      [sz[0][i] - fib.lf / 2. * cos(phi_z[0][i]), sz[0][i] + fib.lf / 2. * cos(phi_z[0][i])], \
                      linewidth = .5)
        #print  i, sx[0][i], lf / 2. * cosphi_x[0][i], [sx[0][i] - lf / 2. * cosphi_x[0][i], sx[0][i] + lf / 2. * cosphi_x[0][i]], \
        #             [sy[0][i] - lf / 2. * cosphi_y[0][i], sy[0][i] + lf / 2. * cosphi_y[0][i]], \
        #              [sz[0][i] - lf / 2. * cosphi_z[0][i], sz[0][i] + lf / 2. * cosphi_z[0][i]]                    
        ax2.add_line(l)
    ax2.plot(sy, sz, 'ro')
    ax2.plot([ -spec.l_y / 2., spec.l_y / 2. ], [spec.l_z / 2., spec.l_z / 2.], 'r-')
    ax2.plot([ -spec.l_y / 2., spec.l_y / 2. ], [-spec.l_z / 2., -spec.l_z / 2.], 'r-')
    ax2.plot([ spec.l_y / 2., spec.l_y / 2. ], [-spec.l_z / 2., spec.l_z / 2.], 'r-')
    ax2.plot([ -spec.l_y / 2., -spec.l_y / 2. ], [-spec.l_z / 2., spec.l_z / 2.], 'r-')
    #ax2.set_xlim( -l_y / 2., l_y / 2. )
    #ax2.set_ylim( -l_z / 2., l_z / 2. )
    title('Fibers in 2D - yz')
    draw()
    return 0
开发者ID:kelidas,项目名称:scratch,代码行数:28,代码来源:specimen3D_fibers.py

示例2: fibers_2d_xy

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_line [as 别名]
def fibers_2d_xy():
    '''
        Plot fibers in 2D section (plane XY)
    '''
    fig3 = figure(5)
    ax3 = Axes(fig3, [.1, .1, .8, .8])

    fig3.add_axes(ax3)
    for i in range(0, len(sx[0])):
        l = Line2D([sx[0][i] - fib.lf / 2. * cos(phi_x[0][i]), sx[0][i] + fib.lf / 2. * cos(phi_x[0][i])], \
                     [sy[0][i] - fib.lf / 2. * cos(phi_y[0][i]), sy[0][i] + fib.lf / 2. * cos(phi_y[0][i])], \
                      linewidth = .5, color = 'black')
        #print  i, sx[0][i], lf / 2. * cosphi_x[0][i], [sx[0][i] - lf / 2. * cosphi_x[0][i], sx[0][i] + lf / 2. * cosphi_x[0][i]], \
        #             [sy[0][i] - lf / 2. * cosphi_y[0][i], sy[0][i] + lf / 2. * cosphi_y[0][i]], \
        #              [sz[0][i] - lf / 2. * cosphi_z[0][i], sz[0][i] + lf / 2. * cosphi_z[0][i]]                    
        ax3.add_line(l)
    ax3.plot(sx, sy, 'ko', markersize = 3.0)
    ax3.plot([ -spec.l_x / 2., spec.l_x / 2. ], [spec.l_y / 2., spec.l_y / 2.], 'k-', linewidth = 2)
    ax3.plot([ -spec.l_x / 2., spec.l_x / 2. ], [-spec.l_y / 2., -spec.l_y / 2.], 'k-', linewidth = 2)
    ax3.plot([ spec.l_x / 2., spec.l_x / 2. ], [-spec.l_y / 2., spec.l_y / 2.], 'k-', linewidth = 2)
    ax3.plot([ -spec.l_x / 2., -spec.l_x / 2. ], [-spec.l_y / 2., spec.l_y / 2.], 'k-', linewidth = 2)
    ax3.set_axis_off()
    #ax3.set_xlim( -l_x / 2., l_x / 2. )
    #ax3.set_ylim( -l_y / 2., l_y / 2. )
    title('Fibers in 2D - xy')
    draw()
开发者ID:kelidas,项目名称:scratch,代码行数:28,代码来源:specimen3D_fibers.py

示例3: display_top_down

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_line [as 别名]
def display_top_down( arrX, arrY ):

    fig = plt.figure(1)
    ax = Axes(fig, [.1,.1,.8,.8]) 
    fig.add_axes(ax)                                           
    l = Line2D( arrX, arrY)                    
    ax.add_line(l)        

    plt.plot( arrX, arrY, 'ro' )
开发者ID:marcinbogdanski,项目名称:robots12,代码行数:11,代码来源:inverse_kinematics_lib.py

示例4: drawG

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_line [as 别名]
def drawG(fig, n, roundN, graphs):
    graphsId = difGraphsId(graphs)
    size = len(graphsId)
    print 'size ', size
    bgnX = 0.1
    bgnY = 0.1
    width = 0.8 / size
    height = 0.35

    for idx in range(size):
        ax = Axes(fig, [bgnX, bgnY, width * 0.9, height])
        ax.set_xticks(range(-1,3))
        ax.set_yticks(range(-1, n+1))
        ax.set_frame_on(False)

        gid = graphsId[idx]
        ax.set_title( 'Round ' + str(gid+1) )

        for i in range(-1, n + 1):
            ax.plot(0, i, marker = 'o')
            ax.plot(1, i, marker = 'o')

        for edge in graphs[gid]:
            nodes = [int(i) for i in edge.split('-')]
            nodes[1] -= n
            line = Line2D([0, 1], nodes)

            if gid == 0:
                line.set_color('b')
            else:
                color = 'r'
                for e in graphs[gid-1]:
                    if edge == e:
                        color = 'b'
                        break
                line.set_color(color)

            ax.add_line( line )

        preId = max(gid-1, 0)
        for edge in graphs[preId]:
            color = 'g'
            for e in graphs[gid]:
                if edge == e:
                    color = 'b'
                    break

            if color == 'g':
                nodes = [int(i) for i in edge.split('-')]
                nodes[1] -= n
                line = Line2D([0, 1], nodes, linestyle= '--')
                line.set_color(color)
                ax.add_line( line )

        fig.add_axes( ax )
        bgnX += width
开发者ID:iSuneast,项目名称:Market,代码行数:58,代码来源:makeLog.py

示例5: figure

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_line [as 别名]
#ax.set_zlabel( 'Z' )



fig2 = figure( 1 )
ax2 = Axes( fig2, [.1, .1, .8, .8] ) 

fig2.add_axes( ax2 )          
for i in range( 0, len( sx[0] ) ):                        
    l = Line2D( [sy[0][i] - lf / 2. * cosphi_y[0][i], sy[0][i] + lf / 2. * cosphi_y[0][i]], \
                  [sz[0][i] - lf / 2. * cosphi_z[0][i], sz[0][i] + lf / 2. * cosphi_z[0][i]], \
                  linewidth=.5 )     
    #print  i, sx[0][i], lf / 2. * cosphi_x[0][i], [sx[0][i] - lf / 2. * cosphi_x[0][i], sx[0][i] + lf / 2. * cosphi_x[0][i]], \
    #             [sy[0][i] - lf / 2. * cosphi_y[0][i], sy[0][i] + lf / 2. * cosphi_y[0][i]], \
    #              [sz[0][i] - lf / 2. * cosphi_z[0][i], sz[0][i] + lf / 2. * cosphi_z[0][i]]                    
    ax2.add_line( l ) 
ax2.plot( sy, sz, 'ro' )
ax2.set_xlim( -6, 6. )
ax2.set_ylim( -6., 6. )
ax2.plot( [ -l_x / 2., l_x / 2. ], [l_y / 2., l_y / 2.], 'r-' )
ax2.plot( [ -l_x / 2., l_x / 2. ], [-l_y / 2., -l_y / 2.], 'r-' )
ax2.plot( [ l_x / 2., l_x / 2. ], [-l_y / 2., l_y / 2.], 'r-' )
ax2.plot( [ -l_x / 2., -l_x / 2. ], [-l_y / 2., l_y / 2.], 'r-' )


                                         
#canvas = FigureCanvasAgg( fig )    
         
#canvas.print_figure( "specimen3D.png" )   
    
开发者ID:kelidas,项目名称:scratch,代码行数:31,代码来源:history.py

示例6: rand

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_line [as 别名]
#sec = rand( 1, n_sec ) * l_x
sec = linspace( 0, l_x, n_sec )
for i in range( 0, n_sec ):
    vec_cut = func( sx, lx, sec[i] )
    v.append( sum( vec_cut ) )
    

    

# plot specimen with fibers
fig = Figure()  #figsize=[4, 4]
ax = Axes( fig, [.1, .1, .8, .8] )                              
fig.add_axes( ax )                
for i in range( 0, len( sx[0] ) ):                        
    l = Line2D( [sx[0][i] - lf / 2. * cosO[0][i], sx[0][i] + lf / 2. * cosO[0][i]], [sy[0][i], sy[0][i]] )#- lf / 2. * sin( arccos( cosO[0][i] ) )                          
    ax.add_line( l ) 
ax.set_xlim( 0, 500 )
ax.set_ylim( 0, 100 )
                                            
canvas = FigureCanvasAgg( fig )    
         
canvas.print_figure( "specimen.png" )   

# plot histogram
pdf, bins, patches = hist( v, 1000, normed=0 ) #, facecolor='green', alpha=1
#plot( sx, sy, 'rx' )   # centroids
#print sum( pdf * diff( bins ) )
show()


开发者ID:kelidas,项目名称:scratch,代码行数:30,代码来源:specimen.py


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