This one used to work fine, but somehow it stopped working (I must have changed something mistakenly but I can't find the issue).
I'm plotting a set of 3 bars per date, plus a line that shows the accumulated value of one of them. But only one or another (either the bars or the line) is properly being plotted. If I left the code for the bars last, only the bars are plotted. If I left the code for the line last, only the line is plotted.
fig, ax = plt.subplots(figsize = (15,8)) df.groupby("date")["result"].sum().cumsum().plot( ax=ax, marker='D', lw=2, color="purple") df.groupby("date")[selected_columns].sum().plot( ax=ax, kind="bar", color=["blue", "red", "gold"]) ax.legend(["LINE", "X", "Y", "Z"])
Appreciate the help!
https://stackoverflow.com/questions/66083506/how-to-properly-plot-a-line-over-bars February 07, 2021 at 08:49AM
没有评论:
发表评论