python 画园和椭圆
2021/7/9 14:36:25
本文主要是介绍python 画园和椭圆,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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()
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.xaxis.set_ticks_position('bottom') # 脊梁’轴 ax.spines['bottom'].set_position(('data', 0)) # 脊梁’的data ax.yaxis.set_ticks_position('left') # 脊梁’轴 ax.spines['left'].set_position(('data', 0)) # 脊梁’的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()
这篇关于python 画园和椭圆的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门