How does giving a title to a chart work?

Course Name: Python for Trading: Basic, Section No: 5, Unit No: 13, Unit type: Quiz

I see that sometimes a title can be added in a code as follow:

data.plot(title = 'Returns')

The course teaches that title can be added using plt.title()

I am confused as to how plt.title() can work without specifying the chart.  Could you please advise?

Hi Robin,



Both methods can be used to add a title to the chart. There’s a difference between the two.  



DataFrame.plot() is a method from the pandas library and you can use data.plot(title = “ ”) to add a title to the chart.



In the course, plt.title() method from the matplotlib library is used to add a title to the chart. The plt.plot() method plots the data, and then the plt.title() method adds a title to the chart.



Hope this helps!



Thanks, 

Bhavika