I would like to have a time series plot including 2 columns - which works fine the way described below. I tried many ways to introduce a label for the secondary y axis with no success.
df.plot(kind='line',
x='measurement_date',
y=['crack_total', "crack_inv_vel"],
secondary_y=["crack_inv_vel"],
xlabel="date",
ylabel="crack width [m]",
title="crack survey")
Example Plot as produced with the code above:-
Assign the return value of df.plot
to a variable; it will be of type matplotlib.axes._subplots.AxesSubplot
. Then twinx
it to get access to the secondary y-axis. Then you can adjust label etc.:
ax = df.plot(kind="line",
x="measurement_date",
y=["crack_total", "crack_inv_vel"],
secondary_y=["crack_inv_vel"],
xlabel="date",
ylabel="crack width [m]",
title="crack survey")
ax_secondary = ax.twinx()
ax_secondary.set_ylabel("secondary y-label")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.