• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

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)) # 底部‘脊梁’移动位置,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()

posted on 2019-12-11 20:26  gisai  阅读(1004)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3