Skip to content Skip to sidebar Skip to footer

Why Can I Create A Plot Using Df.plot, But Then Modify The Plot I See By Calling The Plt Object?

Maybe I'm just missing something really straightforward here. But I know in pandas I can use the matplotlib plotting feature by simply doing dataframe.plot (info here). But how is

Solution 1:

Matplotlib has the concept of the current axes. Essentially what this means is that whenever you first do something that requires an axes object, one is created for you and becomes the default object that all of your future actions will be applied to until you change the current axes to something else. In your case, dataset.plot(x='MinTemp', y='MaxTemp', style='o') creates an axes object and sets it as the current axes. All of plt.title(), plt.xlabel(), and plt.ylabel() simply apply their changes to the current axes.


Post a Comment for "Why Can I Create A Plot Using Df.plot, But Then Modify The Plot I See By Calling The Plt Object?"