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


Python Circle.center方法代码示例

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


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

示例1: make_animation_frames

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import center [as 别名]
def make_animation_frames(name, semimajor, planet_radius, star_radius, star_color, orbital_period):
    #not affiliated with Animal Planet.

    center = np.array([0.5,0.5])
    angle = np.random.uniform(0, 2*np.pi)
    planet_center = center+semimajor*np.array([1,0])

    fig = Figure(figsize=(6,6))
    axis = fig.add_subplot(1, 1, 1)

    star = Circle(center, radius=star_radius, color=star_color)
    orbit = Circle(center, radius=semimajor, fill=False, linestyle='dashed', color='gray')
    planet = Circle(planet_center, radius=planet_radius, color='green')

    axis.add_patch(star)
    axis.add_patch(orbit)
    axis.add_patch(planet)
    axis.axis('off')

    filenames = []
    #set 50 days to be 5 seconds
    orbital_period = orbital_period/100.*5.
    #let's put the period in seconds
    fps = 100.
    print 'orbital period = ', orbital_period
    nframe = int(orbital_period*fps)


    #round off 
    orbital_period = nframe/fps
    omega = 2*np.pi/orbital_period
    angles = np.linspace(0, 2*np.pi, nframe)
    if not os.path.exists("frames"):
        os.makekdir("frames")
    if not os.path.exists("gifs"):
        os.makekdir("gifss")
    print angles
    print "nframe = ", nframe
    for i,theta in enumerate(angles):
        canvas = FigureCanvas(fig)
        planet.center = center+semimajor*np.array([np.cos(theta),np.sin(theta)])
        filename = ("frames/%.4d_"%i)+remove_space(name)+'.png'
        fig.savefig(filename)
        filenames.append(filename)

    #animate
    gifname = "gifs/%s.gif" % remove_space(name)
    frame_names = " ".join(filenames)
    cmd = "convert -delay 1 %s %s" % (frame_names, gifname)
    print cmd   
    os.system(cmd)
开发者ID:RuthAngus,项目名称:exoplanet_travel,代码行数:53,代码来源:exoplanet_pictograms.py


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