這里我利用的是matplotlib.pyplot.plot的工具來繪制折線圖,這里先給出一個(gè)段代碼和結(jié)果圖:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# -*- coding: UTF-8 -*- import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt #這里導(dǎo)入你自己的數(shù)據(jù) #...... #...... #x_axix,train_pn_dis這些都是長度相同的list() #開始畫圖 sub_axix = filter ( lambda x:x % 200 = = 0 , x_axix) plt.title( 'Result Analysis' ) plt.plot(x_axix, train_acys, color = 'green' , label = 'training accuracy' ) plt.plot(sub_axix, test_acys, color = 'red' , label = 'testing accuracy' ) plt.plot(x_axix, train_pn_dis, color = 'skyblue' , label = 'PN distance' ) plt.plot(x_axix, thresholds, color = 'blue' , label = 'threshold' ) plt.legend() # 顯示圖例 plt.xlabel( 'iteration times' ) plt.ylabel( 'rate' ) plt.show() #python 一個(gè)折線圖繪制多個(gè)曲線 |
這里我談?wù)刴atplotlib.pyplot.plot()的使用方法,先附上一個(gè)官方文檔鏈接,然后我說下可能用到的一些參數(shù),參數(shù)可選的內(nèi)容我就不一一展開了,大家可以去上面那個(gè)連接里查:
color:曲線顏色,blue,green,red等等
label:圖例,這個(gè)參數(shù)內(nèi)容就自定義啦,注意如果寫這個(gè)參數(shù)一定要加上plt.legend(),之后再plt.show()才有有用!
linestyle:曲線風(fēng)格,'–','-.',':'等等
linewidth:曲線寬度,自定義就可以
marker:標(biāo)記點(diǎn)樣式,'o','x',也就是說這些符號(hào)會(huì)標(biāo)示出曲線上具體的“點(diǎn)”,這樣一來就易于觀察曲線上那些地方是支撐點(diǎn)
markersize:標(biāo)記點(diǎn)的大小,自定義就可以
后續(xù)有圖表方面的內(nèi)容會(huì)繼續(xù)更新~
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/Touch_Dream/article/details/79402477