神经网络与深度学习——TensorFlow2.0实战(笔记)(六)(Matplotlib绘图基础<折线图和柱状图>python)
生活随笔
收集整理的這篇文章主要介紹了
神经网络与深度学习——TensorFlow2.0实战(笔记)(六)(Matplotlib绘图基础<折线图和柱状图>python)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
折線圖(Line Chart):
散點圖的基礎(chǔ)上,將相鄰的點用線段相連接
plot()函數(shù)
#折線圖:在散點圖的基礎(chǔ)上將相鄰兩個點鏈接 #描述變量變化的趨勢 #plot(x,y,color,marker,label,linewidth,markersize) #x數(shù)據(jù)點的x坐標(biāo) #y數(shù)據(jù)點的y坐標(biāo) #color數(shù)據(jù)點的顏色 #marker數(shù)據(jù)點的樣式 #label圖例文字 #linewidth折線的寬度 #markersize 數(shù)據(jù)點的大小 import numpy as np import matplotlib.pyplot as plt plt.rcParams["font.sans-serif"]="SimHei" plt.rcParams["axes.unicode_minus"]=False #生成隨機數(shù)列 n=24 y1=np.random.randint(27,37,n) y2=np.random.randint(40,60,n) #繪制折線圖 plt.plot(y1,label="溫度") plt.plot(y2,label="濕度") plt.xlim(0,23) plt.ylim(20,70) plt.xlabel("小時",fontsize=12) plt.ylabel("測量值",fontsize=12) plt.title("24小時溫度濕度統(tǒng)計",fontsize=16) plt.legend() plt.show()柱形圖(Bar Chart):
由一系列高度不等的柱形條紋表示數(shù)據(jù)分布的情況
bar()函數(shù)
bar( left, height, width, facecolor, edgecolor, lab)
import numpy as np import matplotlib.pyplot as plt plt.rcParams["font.sans-serif"]="SimHei" plt.rcParams["axes.unicode_minus"]=False #柱狀圖 #bar(left,height,width,facecolor,edgecolor,label) #條紋高度 y1=[32,25,16,30,24,45,40,33,28,17,24,20] y2=[-23,-35,-26,-35,-45,-35,-43,-32,-23,-17,-22,-28] #條紋left坐標(biāo) plt.bar(range(len(y1)),y1,width=0.8,facecolor="green",edgecolor="white",label="統(tǒng)計量1") plt.bar(range(len(y2)),y2,width=0.8,facecolor="red",edgecolor="white",label="統(tǒng)計量2") plt.legend() plt.show()總結(jié)
以上是生活随笔為你收集整理的神经网络与深度学习——TensorFlow2.0实战(笔记)(六)(Matplotlib绘图基础<折线图和柱状图>python)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 信用卡临时额度可以分期吗?信用卡临时额度
- 下一篇: 信用卡提额有困难?巧用分期助你提额!