欢迎来我Python萌新的小站

Python 入门练手100例 – 63

【Python 练习实例63】画椭圆。

【分析】复杂图形或公式可以用Python的第三方库Matplotlib来实现。

椭圆的公式为:

【实例】Demo1:

输出:

Demo2:通过matplotlib中的饼图来画一个“伪”椭圆

输出:

 

喜欢 (0)分享 (0)
(1)个小伙伴在吐槽
  1. 用tkinter
    if __name__ == '__main__':
    	from tkinter import *
    
    	x = 360
    	y = 160
    	top = y - 30
    	bottom = y - 30
    
    	canvas = Canvas(width=400, height=600, bg='white')
    	for i in range(20):
    		canvas.create_oval(250 - top, 250 - bottom, 250 + top, 250 + bottom)
    		top -= 5
    		bottom += 5
    	canvas.pack()
    	mainloop()
    Q_U_E2018-02-28 10:28 回复
发表我的评论
取消评论
友情提示:插入代码时请使用:  <pre>要插入的代码</pre>   以达到最佳效果!

表情     1 + 2 = ? (必填)

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址