當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。