(TIL) Pandas: Accessing additional parameters for a plot

less than 1 minute read

Q:

How can you set parameters such as x- and y-labels? The plot() wrapper for pandas DataFrames doesn’t take those parameters?

A:

The df.plot() function returns a matplotlib.axes.AxesSubplot object. You can set the labels on that object.

>>> ax = df2.plot()
>>> ax.set_xlabel("x label")
>>> ax.set_ylabel("y label")

Via StackOverflow.

Tags: ,

Categories:

Updated:

Comments