久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Python figure參數及subplot子圖繪制代碼

瀏覽:54日期:2022-07-29 15:02:03

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.3plt.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.3plt.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()

Python figure參數及subplot子圖繪制代碼

3. 在同一張圖片上顯示多種圖形,簡單說把 plt.show()放在最后即可

import matplotlib.pyplot as pltimport numpy as npplt.figure(2)x1 = np.linspace(-0.2, 2, 10)y1 = x1**2 + 0.3plt.scatter(x1, y1)x2 = np.linspace(-0.2, 2, 10)y2 = x2 + 0.3plt.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()

Python figure參數及subplot子圖繪制代碼

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 东源县| 利辛县| 承德市| 鄄城县| 通辽市| 新蔡县| 桦甸市| 张家界市| 邢台县| 沐川县| 石门县| 武夷山市| 浮梁县| 昔阳县| 德昌县| 盐津县| 克什克腾旗| 许昌市| 科尔| 兰考县| 舟山市| 德州市| 安陆市| 灵川县| 当阳市| 文山县| 湖北省| 洞口县| 图木舒克市| 厦门市| 留坝县| 石棉县| 无为县| 万山特区| 阿合奇县| 雷山县| 崇文区| 平度市| 清涧县| 黄冈市| 怀宁县|