python 画园和椭圆

Posted gisoracle

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 画园和椭圆相关的知识,希望对你有一定的参考价值。

from matplotlib.patches import Ellipse, Circle
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ell1 = Ellipse(xy = (0.0, 0.0), width = 10, height = 5, angle = 0.0, facecolor= \'yellow\', alpha=0.3)
cir1 = Circle(xy = (0.0, 0.0), radius=2, alpha=0.5)
ax.add_patch(ell1)
ax.add_patch(cir1)

x, y = 0, 0
ax.plot(x, y, \'ro\')

plt.axis(\'scaled\')
ax.spines[\'right\'].set_color(\'none\')  # 设置右‘脊梁’为无色
ax.spines[\'top\'].set_color(\'none\')  # 设置上‘脊梁’为无色
ax.xaxis.set_ticks_position(\'bottom\')  # 底部‘脊梁’设置为X轴
ax.spines[\'bottom\'].set_position((\'data\', 0))  # 底部‘脊梁’移动位置,y的data
ax.yaxis.set_ticks_position(\'left\')  # 左部‘脊梁’设置为Y轴
ax.spines[\'left\'].set_position((\'data\', 0))  # 左部‘脊梁’移动位置,x的data
plt.savefig(\'d:/test2.png\')

#plt.axis(\'equal\')   #changes limits of x or y axis so that equal increments of x and y have the same length

plt.show()

来自:https://www.cnblogs.com/yibeimingyue/p/9916048.html

from matplotlib.patches import Ellipse, Circle
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ell1 = Ellipse(xy = (0.0, 0.0), width = 10, height = 5, angle = 0.0, facecolor= \'yellow\', alpha=0.3)
cir1 = Circle(xy = (0.0, 0.0), radius=2, alpha=0.5)
ax.add_patch(ell1)
ax.add_patch(cir1)

x, y = 0, 0
ax.plot(x, y, \'ro\')

plt.axis(\'scaled\')
ax.spines[\'right\'].set_color(\'none\') # 设置右脊梁为无色
ax.spines[\'top\'].set_color(\'none\') # 设置上脊梁为无色
ax.xaxis.set_ticks_position(\'bottom\') # 底部脊梁设置为X
ax.spines[\'bottom\'].set_position((\'data\', 0)) # 底部脊梁移动位置,ydata
ax.yaxis.set_ticks_position(\'left\') # 左部脊梁设置为Y
ax.spines[\'left\'].set_position((\'data\', 0)) # 左部脊梁移动位置,xdata
plt.savefig(\'d:/test2.png\')

#plt.axis(\'equal\') #changes limits of x or y axis so that equal increments of x and y have the same length

plt.show()

以上是关于python 画园和椭圆的主要内容,如果未能解决你的问题,请参考以下文章

移动椭圆的板绘图代码

为标签绘制抗锯齿椭圆区域

Python使用turtle库绘制椭圆图形(自定义旋转角度大小颜色以及填充)

Python使用turtle库绘制椭圆图形(自定义旋转角度大小颜色以及填充)

网格/格子/椭圆区域的矩阵

python+rabbitMQ抓取某婚恋网站用户数据