在讲解绘制多个子图之前先简单了解一下使用matplotlib绘制一个图,导入绘图所需库matplotlib并创建一个等间隔的列表x,将[0,2*pi]等分为50等份,绘制函数sin(x).当没有给定x轴数值时,默认以下标作为x的值,如果x值确定,则绘图时写为 plt.plot(x,y) . 如若想要绘制一个图时写入标签,则写为 plt.plot(x,y,label="figure1"). from numpy import * import matplotlib.pyplot as p
通过plt.subplot能够在一张图中画出多个子图 #coding: utf-8 #!/usr/bin/env python """ Draw a graph with matplotlib. You must have matplotlib for this to work. """ __author__ = """Aric Hagberg (hagberg@lanl.gov)"""
2D图形 import numpy as np import pandas as pd from pandas import Series,DataFrame import matplotlib.pyplot as plt 散点图 [散点图需要两个参数x,y,但此时x不是表示x轴的刻度,而是每个点的横坐标!] scatter() 通过散点图 可以研究 两个特征之间的关系 x = np.random.normal(loc=0,scale=5,size=1000) y = np.random.nor