程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[P14 Python basics] Python drawing basics Matplotlib

編輯:Python

Python Basis of drawing


matplotlib

matplotlib Official website


Click the required graph to see the implementation code


import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(8,4))
x=np.linspace(0,10,1000)
y=np.sin(x)
z=np.cos(x**2)
plt.plot(x,y,label="sin(x)",color="red",linewidth=2)
plt.plot(x,z,"b--",label="cos(x^2)")# b Blue ,-- Dashed line
plt.xlabel("Time(s)")
plt.ylabel("Value")
plt.title("PyPlot first example")
plt.ylim(-1.2,1.2)#y Axis range -1.2~1.2
plt.legend()# Figure note
plt.savefig('E:/Progarm/Py_Program/1.jpg',dpi=300)# Save the picture ,dpi Save HD pictures , If not set dpi, Default computer resolution ( Pixels per inch )
plt.show()# If you want to save the picture , Must be in show Save before , If you put it in show after , A blank image is saved

If you want to save the picture , Must be in show Save before , If you put it in show after , A blank image is saved


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved