import matplotlib as mpl |
import numpy as np |
import matplotlib.pyplot as plt |
np.random.seed( 2000 ) |
date = np.random.standard_normal(( 20 , 2 )) |
y = date.cumsum(axis = 0 ) |
y[:, 0 ] = y[:, 0 ] * 100 |
plt.figure(figsize = ( 7 , 5 )) # 确定图片大小 |
plt.subplot( 121 ) # 确定第一个图的位置 |
plt.plot(y[:, 0 ], 'b' , label = "1st" ) |
plt.plot(y[:, 0 ], 'ro' ) |
plt.grid( True ) |
plt.axis( 'tight' ) |
plt.xlabel( "Index" ) |
plt.ylabel( 'Values' , size = 20 ) |
plt.title( "1st date set" ) |
plt.legend(loc = 0 ) |
plt.subplot( 122 ) # 确定第一个图的位置 |
plt.bar(np.arange( len (y[:, 1 ])), y[:, 1 ], width = 0.5 , color = 'g' , label = "2nd" ) # 直方图的画法 |
plt.grid( True ) |
plt.xlabel( "Index" ) |
plt.title( '2nd date set' ) |
plt.legend(loc = 0 ) |
plt.show() |