• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Python figure参数及subplot子图绘制代码

python 搞代码 4年前 (2022-01-07) 29次浏览 已收录 0个评论

这篇文章主要介绍了Python figure参数及subplot子图绘制代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

1. Python的figure参数主要有:

 def figure(num=None, # autoincrement if None, else integer from 1-N figsize=None, # defaults to rc figure.figsize dpi=None, # defaults to rc figure.dpi facecolor=None, # defaults to rc figure.facecolor edgecolor=None, # defaults to rc figure.edgecolor frameon=True, FigureClass=Figure, clear=False, **kwargs ):

可以设置图片大小、分辨率、颜色等。

2. subplot子图绘制,子图的绘图参数可以分别设置

 plt.figure(1) x1 = np.linspace(-0.2, 2, 10) y1 = x1**2 + 0.3 plt.subplot(121) plt.scatter(x1, y1) plt.xlabel('X') plt.ylabel('Y') plt.title('test_1') x2 = np.linspace(-0.2, 2, 10) y2 = x2 + 0.3 plt.subplot(122) plt.plot(x2, y2, color="red", linewidth=1.0, marker = 's', linestyle="--") ## plt.plot(x, y, color="#ef5492", linewidth=2.0, marker = 's', linestyle="--") # plt.plot(x2, y2, 'rs--') plt.xlabel('X') plt.ylabel('Y') plt.title('test_2') plt.show()

3. 在同一张图片上显示多种图形,简单说把 plt.show()放在最后即可

 import matplotlib.pyplot as plt import numpy as np plt.figure(2) x1 = np.linspace(-0.2, 2, 10) y1 = x1**2 + 0.3 plt.scatter(x1, y1) x2 = np.linspace(-0.2, 2, 10) y2 = x2 + 0.3 plt.plot(x2, y2, color="red", linewidth=1.0, marker = 's', linestyle="--") ## plt.plot(x, y, color="#ef5492", linewidth=2.0, marker = 's', linestyle="--") # plt.plot(x2, y2, 'rs--') plt.xlabel('X') plt.ylabel('Y') plt.title('test_3') plt.show()

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持gaodaima搞代码网

以上就是Python figure参数及subplot子图绘制代码的详细内容,更多请关注ga来源gaodai$ma#com搞$$代**码网odaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Python figure参数及subplot子图绘制代码
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

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

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