1. 程式人生 > >python matplotlib 簡單生成圖

python matplotlib 簡單生成圖

分享 rand nor bsp panda fig das inf lib

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
data = pd.DataFrame([[1,2,3],[11,22,33],[111,222,333]])

data.plot() #plot()默認的線性圖

技術分享圖片

#點狀隨機圖

from numpy import random
from matplotlib import pyplot
def drawScatter():
heights = []
weights = []
heights.append(random.normal(172,6,size=50))

weights.append(random.normal(50,100,size=50))

pyplot.scatter(heights,weights)
pyplot.xlabel(‘身高cm‘)
pyplot.xlabel(‘體重kg‘)
pyplot.title(‘身高vs體重散點圖‘)
pyplot.savefig(‘test.png‘)
pyplot.show()
drawScatter()

技術分享圖片

python matplotlib 簡單生成圖