-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: pd_df.plot
issue: plotting several pd_df
on the same figure, sometimes works, sometimes not
#54561
Comments
Can you please cut down your example to be minimal and copy-pastable? I'm not going to run code involving pickle files due to security concerns with pickle. |
I updated dumping the pd df:s as csv. Now running the exact same code, I get a figure with 2 curves, but the x-axis is messed up (both curves should last for nearly the same duration), and the x-ticks look weird (the x-ticks looked much better in the previous plot of the exact same dataset). I do not know if this is considered a bug or not, but from a user perspective it feels a bit brittle, so if this could be improved on / a way to do this better could be provided, this would be very useful :) . See: The code to run reduces to: import pandas as pd
import datetime
import matplotlib.pyplot as plt
pd.show_versions()
df_pytmd = pd.read_csv("./df_pytmd.csv")
df_xr_obs = pd.read_csv("./df_xr_obs.csv")
# plotting...
# keeping this for now, to report issue to pandas
# this should work but plot is empty!
# actually not empty any longer, but looks ugly with the X-axis!
fig = plt.figure()
ax = plt.gca()
#
df_pytmd.plot(x="utc_timestamp", y=["pytmd_u"], ax=ax)
#
df_xr_obs.plot(x="utc_timestamp", y=["xr_obs_u"], ax=ax)
#
plt.show()
# while both plots individually work
# plot 1
fig = plt.figure()
ax = plt.gca()
#
df_pytmd.plot(x="utc_timestamp", y="pytmd_u", ax=ax)
#
plt.show()
# plot 2
fig = plt.figure()
ax = plt.gca()
#
df_xr_obs.plot(x="utc_timestamp", y=["xr_obs_u"], ax=ax)
#
plt.show() |
Thanks for the report, but for testing, we would need a more minimal example not involving files for unit testing concerns. Going to close for now but happy to reopen if you're able to able to reproduce with synthetic, in memory data |
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
See the notebooks at:
Basically, all works fine in the first notebook. In the second notebook, doing exactly the same trick of .ploting twice on the same figure, I get an empty figure.
Issue Description
As visible in https://github.com/jerabaul29/public_bug_reports/blob/main/pandas/2023_08_15/SimpleScriptGetTideCurrentTimeseries.ipynb :
Expected Behavior
This should plot both curves on the same figure.
Installed Versions
INSTALLED VERSIONS
commit : 0f43794
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-78-generic
Version : #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.0.3
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.0.0
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : 1.0.9
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : 2023.7.0
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: