Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas dataframe hexbin plot has no xlabel or axis values

I am trying to plot a dataframe as hexbin but can't seem to get the xlabel and x-axis values to plot. The dataframe is as follows:

szen_df.xs('left', level='pos')

enter image description here

and the plot is as follows:

szen_df.xs('left', level='pos').plot(x='szen', y='lat', xlim=(0,90), ylim=(-90,90), kind='hexbin', colormap='Reds' )

with result:

enter image description here

like image 336
Jacques MALAPRADE Avatar asked Jul 04 '15 11:07

Jacques MALAPRADE


2 Answers

I'm seeing this problem as well with python 2.7, pandas 0.16.2.dev, and ipython version 3.1.0.

Looking to the documentation for pandas.DataFrame.plot, the only reference to the x labels and ticks being invisible is in the sharex option. So, I manually set sharex=False, and poof, the xlabel and xticks come back.

Clearly this is a bug, but I hope this helps for the time being. I'll add these comments to the bug report that you've already started.

like image 175
Bryan Dannowitz Avatar answered Sep 19 '22 14:09

Bryan Dannowitz


Looks like the same as the issue I had here: matplotlib scatterplot x axis labels

The workaround which worked was to set the axes explicitly. Just leaving this here for the future :)

Might be connected with https://github.com/pandas-dev/pandas/pull/12949 , Open as of now (6th of April 17)

like image 30
CatInABox Avatar answered Sep 21 '22 14:09

CatInABox