# -*- coding: utf-8 -*-
#先画一个线性图
import numpy as np
import matplotlib.pyplot as plt
 
x=[0,1]
y=[0,1]
 
plt.figure()
plt.plot(x,y)
plt.xlabel("time(s)")
plt.ylabel("value(m)")
plt.title("A simple plot by NO.32")

Matplotlib的初次使用

 

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
 
#设置x,y轴的数值(y=sinx)
x = np.linspace(0, 10, 1000)
y = np.sin(x)
 
#创建绘图对象,figsize参数可以指定绘图对象的宽度和高度,单位为英寸,一英寸=80px
plt.figure(figsize=(8,4))
 
#在当前绘图对象中画图(x轴,y轴,给所绘制的曲线的名字,画线颜色,画线宽度)
plt.plot(x,y,label="$sin(x)$",color="red",linewidth=2)
 
#X轴的文字
plt.xlabel("Time(s)")
 
#Y轴的文字
plt.ylabel("Volt")
 
#图表的标题
plt.title("PyPlot First Example")
 
#Y轴的范围
plt.ylim(-1.2,1.2)

Matplotlib的初次使用

 

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2021-09-01
  • 2021-07-05
  • 2021-10-30
  • 2022-01-13
  • 2021-12-20
  • 2021-08-16
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2021-11-20
  • 2021-08-14
  • 2021-10-30
  • 2021-05-26
  • 2021-09-05
相关资源
相似解决方案