最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Python figure参数及subplot子图绘制代码实例
时间:2020-04-18 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下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", line.0, marker = 's', linestyle="--") ## plt.plot(x, y, color="#ef5492", line.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", line.0, marker = 's', linestyle="--") ## plt.plot(x, y, color="#ef5492", line.0, marker = 's', linestyle="--") # plt.plot(x2, y2, 'rs--') plt.xlabel('X') plt.ylabel('Y') plt.title('test_3') plt.show()
相关文章
- Golang ProtoBuf的基本语法详解 10-20
- Python识别MySQL中的冗余索引解析 10-20
- Python+Pygame绘制小球代码展示 10-18
- Python中的数据精度问题介绍 10-18
- Python随机值生成的常用方法介绍 10-18
- python3解压缩.gz文件分析 09-27