Python可視化學習筆記一

from matplotlib.pyplot import *
import matplotlib.pyplot as plt

def learn_1():
#plot儲存數據集,多組數據展現多條線
”’
plot([1,2,3,2,3,2,2,1])
plot([4,3,2,1],[1,2,3,4])
”’
x=[1,2,3,4]
y=[5,4,3,2]
figure()

subplot(231)
plot(x,y)

subplot(232)
bar(x,y)

subplot(233)
barh(x,y)

subplot(234)
bar(x,y)

y1=[7,8,5,3]
bar(x,y1,bottom=y,color='r')

subplot(235)
boxplot(x)

subplot(236)
scatter(x,y)

plt.show()

if name == ‘main‘:
learn_1()
此代碼分4部分:
1、導入合適的包
2、建立數據源
3、劃分子圖板塊
4、函數調用顯示

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章