-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: axvspan
breaks when using pandas .plot()
wrapper
#51795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @DanielHabenicht , When I run the code, I got the same result as it was expected to show for using axvspan() after df.plot(). Regarding why the stuff works different when applied to different position is when you call On the other hand, when you call You can play around with |
Hi @ritikBhandari, thanks for taking the time to reproduce the issue. I did try it with zorder, as you can see in my example. It did not change the result:
So in short, you can't reproduce it? Then I will try to reproduce it on another machine. One more question: |
So I tried to reproduce the code and it is showing me the shades when I apply And regarding why it isn't applying shades when used before |
Alright, seems like I also can't reproduce the But I would still expect that: ax.axvspan(start, end)
ax.plot(df.index, df["n1"], linestyle="solid", zorder=3) behaves the same as: ax.axvspan(start, end)
df.plot(ax=ax, linestyle="solid", zorder=3) |
I didn't reproduce the exact same issue but I'm fairly certain this is the same underlying issue as #52895; |
Closing as a similar issue to #52895 |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Using the wrapper functions somehow generates weird behaviour for plotting.
Interestingly only with the data I used here: export.csv
Using the

axvspan
beforedf.plot()
:Using the

axvspan
afterdf.plot()
:Expected Behavior
Using

axvspan
before and afterdf.plot
or using the standardax.plot(x,y)
function:Related
There was some weirdness reported before; #5092
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.10.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.90.1-microsoft-standard-WSL2
Version : #1 SMP Fri Jan 27 02:56:13 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.3
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 67.4.0
pip : 23.0
Cython : None
pytest : 7.2.1
hypothesis : None
...
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: