matplotlib Basic

Steven Wang
1 min readJan 1, 2019

--

import numpy as np
import matplotlib.pyplot as plt
a=[1,2,3]
b=[4,5,6]
plt.plot(a,b) #x=a y=b
plt.show()

%matplotlib inline #jupyter可以不用每次plt.show()
plt.plot(a,b) #這裏馬上就畫出 不用plot.show()

plt.plot(a,b,’- -’)#虛線
plt.plot(a,b,’*’)#星號

c=[10,8,6]
d=[1,8,3]
plt.plot(a,b,’- -’,c,d,’*’)

t=np.arange(0.0,2.0,0.1)
s=np.sin(t*np.pi)
plt.plot(t,s,’r- -’,label=’aaaa’) #label
plt.plot(t*2,s,’b- -’,label=’bbbb’)
plt.xlabel(‘this is x’) #xlabel
plt.ylabel(‘this is y’) #ylebel
plt.title(‘this is d title demo’) #title
plt.legend() #legend

--

--

Steven Wang
Steven Wang

No responses yet