pandas: xticks missing for scatter plots with colors
example: https://www.wakari.io/sharing/bundle/adamgreenhall/test-scatter
I think this happens specifically for pandas scatter plots with colorbars in ipython. The xticks are still working for:
- non-colorbar pandas scatter plots
- the same scatter plot using matplotlib
- standard python scripts using
plt.savefig
related problem with %matplotlib inline?: https://github.com/ipython/ipython/issues/1443/
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 13
- Comments: 35 (26 by maintainers)
Links to this issue
Commits related to this issue
- use locally defined _get_xticks instead of matplotlib default ax.get_xticks() fixes #10611 — committed to brownsarahm/pandas by deleted user 6 years ago
sharex=Falseis better workaround, see answer on SO: http://stackoverflow.com/a/31633381/2230844I hit this bug as well, and I found a solution that add one ax.
https://stackoverflow.com/questions/52631031/make-pandas-plot-show-xlabel-and-xvalues
This was resolved in the master for a while but seems to have returned since 0.24.0.
Example code:
output:
I think the culprit is: https://github.com/pandas-dev/pandas/blob/d3c9d6e67491caf9046b0f8efd2d8d153b52b8e3/pandas/plotting/_core.py#L833
Note that this only happens in the inline backend.
Output of
pd.show_versions()INSTALLED VERSIONS
commit: None python: 3.6.8.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-43-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8
pandas: 0.24.1 pytest: 4.1.1 pip: 18.1 setuptools: 40.6.3 Cython: 0.29.2 numpy: 1.15.4 scipy: 1.2.0 pyarrow: None xarray: None IPython: 7.2.0 sphinx: 1.8.2 patsy: None dateutil: 2.7.5 pytz: 2018.9 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 3.0.2 openpyxl: None xlrd: 1.2.0 xlwt: 1.3.0 xlsxwriter: None lxml.etree: 4.3.0 bs4: None html5lib: 0.9999999 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: 0.8.0 pandas_datareader: None gcsfs: None
I encountered this bug also. See screenshots of the two versions of the plot, one with colors, one without. The full notebook (without output, as it’s still WiP) is at: http://go.gwu.edu/engcomp2lesson4
Hardcoding
sharex=Falsecould break subplots.@tacaswell maybe you have a quick answer. With
Is there any way to disable the update done to the x axis ticks (not sure if it’s the tick labels or something else) in the
plt.colorbarcall?With matplotlib that gives
with pandas
gives