1、plt.tight_layout()(https://blog.csdn.net/weixin_45492560/article/details/113625605)
https://blog.csdn.net/qq_41870157/article/details/104615338
2诱建、python xticks()函數(shù)設(shè)置X軸方法--刻度稀并、標(biāo)簽(https://blog.csdn.net/u011208984/article/details/90720516)
plt.xticks(()) # 設(shè)置坐標(biāo)軸不顯示坐標(biāo)
3仅颇、python中plt.cm.Paired (https://www.csdn.net/tags/NtzaQgzsMDk4MTgtYmxvZwO0O0OO0O0O.html)
plt.cm中cm全稱表示colormap,
paired表示兩個(gè)相近色彩輸出碘举,比如淺藍(lán)忘瓦、深藍(lán) ;淺紅引颈、深紅耕皮;淺綠,深綠這種蝙场。
4凌停、Python Matplotlib屬性 cmap(https://blog.csdn.net/yzxnuaa/article/details/89528971)
cmap即colormaps
獲取圖譜使用plt.get_cmap(‘xxx’)
5、plt.scatter()函數(shù)解析(最清晰的解釋)(https://blog.csdn.net/qq_36387683/article/details/101378036)
https://zhuanlan.zhihu.com/p/111331057
plt.scatter(x, y, s=area, c=colors, linewidths=widths, alpha=0.5, marker='o')
s:表示的是大小售滤,是一個(gè)標(biāo)量或者是一個(gè)shape大小為(n,)的數(shù)組罚拟,可選台诗,默認(rèn)20。
c:表示的是色彩或顏色序列赐俗,可選拉队,默認(rèn)藍(lán)色’b’。但是c不應(yīng)該是一個(gè)單一的RGB數(shù)字阻逮,也不應(yīng)該是一個(gè)RGBA的序列粱快,因?yàn)椴槐銋^(qū)分。c可以是一個(gè)RGB或RGBA二維行數(shù)組夺鲜。
alpha → 散點(diǎn)透明度([0, 1]之間的數(shù)皆尔,0表示完全透明,1則表示完全不透明)
linewidths →散點(diǎn)的邊緣線寬
edgecolors → 散點(diǎn)的邊緣顏色
6币励、plt.axis (https://www.jb51.net/article/192470.htm)
https://blog.csdn.net/qq_36439087/article/details/121527402
plt.axis([a, b, c, d]) 設(shè)置x軸的范圍為[a, b]慷蠕,y軸的范圍為[c, d]
plt.axis('tight') # 坐標(biāo)軸適應(yīng)數(shù)據(jù)量 axis 設(shè)置坐標(biāo)軸
7、matplotlib畫直方圖 - plt.hist() (https://blog.csdn.net/weixin_45520028/article/details/113924866)
x: 作直方圖所要用的數(shù)據(jù)食呻,必須是一維數(shù)組流炕;多維數(shù)組可以先進(jìn)行扁平化再作圖;必選參數(shù)仅胞;
bins: 直方圖的柱數(shù)每辟,即要分的組數(shù),默認(rèn)為10干旧;
range:元組(tuple)或None渠欺;剔除較大和較小的離群值,給出全局范圍椎眯;如果為None挠将,則默認(rèn)為(x.min(),
8、plt.tight_layout() (https://blog.csdn.net/Du_Shuang/article/details/84139716)
tight_layout會(huì)自動(dòng)調(diào)整子圖參數(shù)编整,使之填充整個(gè)圖像區(qū)域舔稀。這是個(gè)實(shí)驗(yàn)特性,可能在一些情況下不工作掌测。它僅僅檢查坐標(biāo)軸標(biāo)簽内贮、刻度標(biāo)簽以及標(biāo)題的部分。
9汞斧、python畫contour等高線圖(https://zhuanlan.zhihu.com/p/108450749)
10夜郁、plt.bar畫柱狀圖(https://blog.csdn.net/fanchui5287/article/details/106157133/)
https://blog.csdn.net/weixin_45520028/article/details/113919561
plt.bar():正常柱狀圖????,常見的統(tǒng)計(jì)圖断箫;
plt.barh():橫向的柱狀圖拂酣,可以理解為正常柱狀圖旋轉(zhuǎn)了90°。
11仲义、plt.cm.Spectral實(shí)現(xiàn)的功能是給label為1的點(diǎn)一種顏色婶熬,給label為0的點(diǎn)另一種顏色剑勾。(https://blog.csdn.net/xc_zhou/article/details/87288253)
生成兩種顏色,其中1,2,5,6是一種赵颅,3,4是一種
colors = plt.cm.Spectral([1,1,0,0,1,1])
print(colors)
12虽另、subplots_adjust(https://blog.csdn.net/asty9000/article/details/88881499)
調(diào)整子圖布局
wspace、hspace分別表示子圖之間左右饺谬、上下的間距
13捂刺、# Python Matplotlib.colors.ListedColormap用法及代碼示例
matplotlib.colors.ListedColormap類用于從顏色列表創(chuàng)建colarmap對象
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors
a = np.linspace(-3, 3)
A, B = np.meshgrid(a, a)
X = np.exp(-(A2 + B2))
figure, (axes1, axes2) = plt.subplots(ncols = 2)
colors =["green", "orange",
"gold", "blue", "k",
"#550011", "purple",
"red"]
axes1.set_title(" color list")
contour = axes1.contourf(A, B, X,
colors = colors)
axes2.set_title("with colormap")
cmap = matplotlib.colors.ListedColormap(colors)
contour = axes2.contourf(A, B, X, cmap = cmap)
figure.colorbar(contour)
plt.show()
14、c argument looks like a single numeric RGB or RGBA sequence, which should be avoi(https://blog.csdn.net/qq_45261963/article/details/117995505)
?問題描述:c這個(gè)參數(shù)應(yīng)該是一個(gè)RGB或RGBA序列募寨,當(dāng)你僅僅需要使用一個(gè)顏色時(shí)族展,應(yīng)該使用顏色單詞來代替,當(dāng)你真的想使用光譜來自定義顏色拔鹰,請你使用二維數(shù)組來確定顏色R歉住!列肢!
?我們上述代碼中自定義的顏色是一個(gè)元組恰画,不符合規(guī)定的二維數(shù)組,需將其轉(zhuǎn)換二維數(shù)組4陕怼K┗埂!
np.array(color1).reshape(1,-1)
15欧聘、plt.figure(1)是什么意思(https://www.imooc.com/qadetail/246860)
plt.figure(1)是新建一個(gè)名叫 Figure1的畫圖窗口片林,plt.plot(x,c)是在畫圖窗口里具體繪制橫軸為x 縱軸為c的曲線
16、fig.add_subplot()函數(shù)參數(shù)的意思(https://blog.csdn.net/wyf2017/article/details/109297737)
fig.add_subplot(111) 一行一列第一個(gè)
fig.add_subplot(221) 2行2列第一個(gè)
17怀骤、plt.imshow()和plt.show()的區(qū)別(https://zhuanlan.zhihu.com/p/72610557)
imshow()接收一張圖像拇厢,只是畫出該圖,并不會(huì)立刻顯示出來晒喷。
imshow后還可以進(jìn)行其他draw操作,比如scatter散點(diǎn)等访敌。
所有畫完后使用plt.show()才能進(jìn)行結(jié)果的顯示凉敲。
(https://blog.csdn.net/weixin_41978699/article/details/120999916)
18、subplot超過十個(gè)子圖
x = np.arange(100)
創(chuàng)建圖像布局對象fig
fig = plt.figure(figsize = (60, 30))
ax1 = fig.add_subplot(3,5,1)
ax1.hist(all_data['飛靶號(hào)'])
ax1.set_title('飛靶號(hào)',fontsize=48)
ax2 = fig.add_subplot(3,5,2)
ax2.hist(all_data['槽號(hào)'])
ax2.set_title('槽號(hào)',fontsize=48)
ax3 = fig.add_subplot(3,5,3)
ax3.hist(all_data['溫度'])
ax3.set_title('溫度',fontsize=48)
ax4 = fig.add_subplot(3,5,4)
ax4.hist(all_data['機(jī)種'])
ax4.set_title('機(jī)種',fontsize=48)
ax5 = fig.add_subplot(3,5,5)
ax5.hist(all_data['桿號(hào)'])
ax5.set_title('桿號(hào)',fontsize=48)
ax6 = fig.add_subplot(3,5,6)
ax6.hist(all_data['PH'])
ax6.set_title('PH',fontsize=48)
ax7 = fig.add_subplot(3,5,7)
ax7.hist(all_data['一次染時(shí)'])
ax7.set_title('一次染時(shí)',fontsize=48)
ax8 = fig.add_subplot(3,5,8)
ax8.hist(all_data['位置'])
ax8.set_title('位置',fontsize=48)
ax9 = fig.add_subplot(3,5,9)
ax9.hist(all_data['L'])
ax9.set_title('L',fontsize=48)
ax10 = fig.add_subplot(3,5,10)
ax10.hist(all_data['A'])
ax10.set_title('A',fontsize=48)
ax11 = fig.add_subplot(3,5,11)
ax11.hist(all_data['B'])
ax11.set_title('B',fontsize=48)
ax12= fig.add_subplot(3,5,12)
ax12.hist(all_data['二次染時(shí)'])
ax12.set_title('二次染時(shí)',fontsize=48)
ax13 = fig.add_subplot(3,5,13)
ax13.hist(all_data['L.1'])
ax13.set_title('L.1',fontsize=48)
ax14= fig.add_subplot(3,5,14)
ax14.hist(all_data['A.1'])
ax14.set_title('A.1',fontsize=48)
ax15= fig.add_subplot(3,5,15)
ax15.hist(all_data['B.1'])
ax15.set_title('B.1',fontsize=48)
plt.show()
19寺旺、Glyph missing from current font.(https://blog.csdn.net/adminkeys/article/details/111207736)
plt.rcParams['font.sans-serif']=['SimHei'] #顯示中文標(biāo)簽
plt.rcParams['axes.unicode_minus']=False
20爷抓、matplotlib 坐標(biāo)字體大小