Python figure參數(shù)及subplot子圖繪制代碼
更新時(shí)間:2020年04月18日 11:16:05 作者:落日峽谷
這篇文章主要介紹了Python figure參數(shù)及subplot子圖繪制代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
1. Python的figure參數(shù)主要有:
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
):
可以設(shè)置圖片大小、分辨率、顏色等。
2. subplot子圖繪制,子圖的繪圖參數(shù)可以分別設(shè)置
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()

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用opencv相關(guān)函數(shù)確定圖片中的直線問題
這篇文章主要介紹了使用opencv相關(guān)函數(shù)確定圖片中的直線問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11
詳解KMP算法以及python如何實(shí)現(xiàn)
這篇文章主要介紹了KMP算法的相關(guān)知識以及python如何實(shí)現(xiàn),幫助大家更好的進(jìn)行數(shù)據(jù)分析,感興趣的朋友可以了解下2020-09-09
用Python PIL實(shí)現(xiàn)幾個(gè)簡單的圖片特效
這篇文章主要介紹了用Python PIL實(shí)現(xiàn)幾個(gè)簡單的圖片特效,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-01-01
Django實(shí)現(xiàn)auth模塊下的登錄注冊與注銷功能
這篇文章主要介紹了Django實(shí)現(xiàn)auth模塊下的登錄注冊與注銷功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-10

