天天看点

python 的 matplotlib画图 画曲线图_python 的 matplotlib画图 画曲线图

#encoding:utf-8

#1.绘制曲线:

import numpy as np

import matplotlib.pyplot as plt

x = np.linspace(0, 10, 1000)

y = np.sin(x)

plt.figure(figsize=(8,4)) plt.plot(x,y,label="$sin(x)$",color="red",linewidth=2)

plt.xlabel("Time(s)")

plt.ylabel("Volt")

plt.title("PyPlot First Example")

plt.ylim(-1.2,1.2)

plt.show()

"""

通过一系列函数设置当前Axes对象的各个属性:

xlabel、ylabel:分别设置X、Y轴的标题文字。

title:设置子图的标题。

xlim、ylim:分别设置X、Y轴的显示范围。

"""

原文地址:http://blog.csdn.net/blog_empire/article/details/42393609