python中繪圖時(shí)改背景顏色的方法-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)www.cdcxhl.cn八線動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買多久送多久,劃算不套路!

祿勸網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),祿勸網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為祿勸上1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的祿勸做網(wǎng)站的公司定做!

不懂python中繪圖時(shí)改背景顏色的方法?其實(shí)想解決這個(gè)問題也不難,下面讓小編帶著大家一起學(xué)習(xí)怎么去解決,希望大家閱讀完這篇文章后大所收獲。

python中一般使用matplotlib庫(kù)進(jìn)行繪圖,下面我們就來看一下python中繪圖時(shí)修改背景顏色的方法:

子圖可以對(duì)plt.subplot的參數(shù)做修改,下面是對(duì)子圖的背景顏色修改代碼:

import matplotlib.pyplot as plt
import numpy as np
 
# Fixing random state for reproducibility
np.random.seed(19680801)
 
dt = 0.01
t = np.arange(0, 30, dt)
nse1 = np.random.randn(len(t))         # white noise 1
nse2 = np.random.randn(len(t))         # white noise 2
s1 = np.sin(2 * np.pi * 10 * t) + nse1
s2 = np.sin(2 * np.pi * 10 * t) + nse2
s3 = np.sin(2 * np.pi * 10 * t) + nse1
s4 = np.sin(2 * np.pi * 10 * t) + nse2
 
fig= plt.figure(1) # 創(chuàng)建圖表1
axs0=plt.subplot(221,facecolor='#FFDAB9') #在圖標(biāo)1中創(chuàng)建子圖
axs0.plot(t, s1) #橫軸與縱軸數(shù)據(jù)
axs0.set_xlim(0, 2) #限制x軸的取值范圍
axs1=plt.subplot(222,facecolor='#7FFF00')
axs1.plot(t, s2)
axs1.set_xlim(0, 2)
axs2=plt.subplot(223,facecolor='#FF7F50')
axs2.plot(t, s3)
axs2.set_xlim(0, 2)
axs3=plt.subplot(224,facecolor='#A9A9A9')
axs3.plot(t, s4)
axs3.set_xlim(0, 2)
 
plt.show()

效果如下:

python中繪圖時(shí)改背景顏色的方法

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享python中繪圖時(shí)改背景顏色的方法內(nèi)容對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道,遇到問題就找創(chuàng)新互聯(lián),詳細(xì)的解決方法等著你來學(xué)習(xí)!

網(wǎng)頁題目:python中繪圖時(shí)改背景顏色的方法-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://www.muchs.cn/article14/dssoge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器網(wǎng)站導(dǎo)航、網(wǎng)站制作企業(yè)建站、App設(shè)計(jì)、微信小程序

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司