使用matplotlib的图表图例和标题

时间:2016-09-27 15:36:11

标签: pandas matplotlib

我正在使用谷歌图表绘制以下数据框。

 Group  G1  G2
 Hour
  6     19  1
  8     1   2

我在折线图中绘制了上述数据框。但我无法在折线图中添加图例和标题。而且,我试图增加折线图的大小,因为它看起来非常小。不确定我们是否在matplotlib中有这些选项。任何帮助将不胜感激。

import matplotlib.pyplot as plt
plt.plot(dft2)
plt.xlabel('Hour')
plt.ylabel('Count')
plt.show()

1 个答案:

答案 0 :(得分:1)

dfg2.plot(legend=True, figsize=(8,8))
plt.legend(ncol=3,  bbox_to_anchor=[1.35, 1], handlelength=2, handletextpad=1, columnspacing=1, title='Legend')

plt.title('Title here!', color='black', fontsize=17)              
plt.xlabel('Hour', fontsize=15)
plt.ylabel('Count', fontsize=15)
plt.show()