import pandas_datareader as web # not part of pandas; conda or pip install
import pandas as pd
import matplotlib.pyplot
# get test data
df = web.DataReader('^gspc', data_source='yahoo', start='2020-09-01', end='2020-09-28').iloc[:, :4]
# set figure
fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(8, 8))
# plot to different axes
df.High.plot.hist(bins=100, alpha=0.8, ax=ax[0, 0])
df.Low.plot.hist(bins=100, alpha=0.8, ax=ax[0, 1])
df.Open.plot.hist(bins=100, alpha=0.8, ax=ax[1, 0])
df.Close.plot.hist(bins=100, alpha=0.8, ax=ax[1, 1])
plt.tight_layout()
plt.show()
axes
相关问题 更多 >
编程相关推荐