Python Scipy Tutorials:Matplot

来源:互联网 发布:网络测线器 编辑:程序博客网 时间:2024/05/18 09:54
# -*- coding: utf-8 -*-"""Python Version: 3.5Created on Fri May 12 14:06:44 2017E-mail: Eric2014_Lv@sjtu.edu.cn@author: DidiLv"""import numpy as npimport matplotlib.pyplot as plt# Compute the x and y coordinates for points on a sine curvex = np.arange(0, 3 * np.pi, 0.1)y = np.sin(x)# Plot the points using matplotlibplt.plot(x, y)plt.show()  # You must call plt.show() to make graphics appear.# Compute the x and y coordinates for points on sine and cosine curvesx = np.arange(0, 3 * np.pi, 0.1)y_sin = np.sin(x)y_cos = np.cos(x)# Set up a subplot grid that has height 2 and width 1,# and set the first such subplot as active.plt.subplot(2, 1, 1)# Make the first plotplt.plot(x, y_sin)plt.title('Sine')# Set the second subplot as active, and make the second plot.plt.subplot(2, 1, 2)plt.plot(x, y_cos)plt.title('Cosine')# Show the figure.plt.show()
0 0