user3447653
user3447653

Reputation: 4158

Legend and title to line charts using matplotlib

I am plotting the below data frame using google charts.

 Group  G1  G2
 Hour
  6     19  1
  8     1   2

I have plotted the above dataframe in line chart. But i am not able to add legend and title to the line chart. And also, I am trying to increase the size of the line charts as it appears to be very small. Not sure whether do we have these options in matplotlib. Any help would be appreciated.

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

Upvotes: 1

Views: 330

Answers (1)

Erba Aitbayev
Erba Aitbayev

Reputation: 4333

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()

Upvotes: 1

Related Questions