我正在尝试在图片Sample Graph here
中绘制附图import matplotlib.pyplot as plt
import pandas as pd
data_set= [
{'date':'2018-05-20','server':'server1','api':'api1','count':4},
{'date':'2018-05-21','server':'server1','api':'api1','count':6},
{'date':'2018-05-22','server':'server1','api':'api1','count':10},
{'date':'2018-05-23','server':'server1','api':'api1','count':10},
{'date':'2018-05-24','server':'server1','api':'api1','count':14},
{'date':'2018-05-20','server':'server1','api':'api2','count':20},
{'date':'2018-05-21','server':'server1','api':'api2','count':22},
{'date':'2018-05-22','server':'server1','api':'api2','count':20},
{'date':'2018-05-23','server':'server1','api':'api2','count':23},
{'date':'2018-05-24','server':'server1','api':'api2','count':20},
{'date':'2018-05-24','server':'server2','api':'api1','count':30},
{'date':'2018-05-21','server':'server2','api':'api2','count':20}]
f, (axs) = plt.subplots(3, sharex=True, sharey=True)
df = pd.DataFrame(data_set)
df['date'] = pd.to_datetime(df['date'],format='%Y/%m/%d %H:%M:%S')
df = df.set_index('date')
grouped = df.groupby(['api'])
for (name, df1), ax in zip(grouped, axs.flat):
df1.plot(y='count', ax=ax)
plt.legend(bbox_to_anchor=(1, 1, 0.25, -0.2), bbox_transform=plt.gcf().transFigure)
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
我没有得到我想要的结果,有人可以指导我吗?
这是我现在得到的图表。 Currently getting this Image