pandas dataframe hexbin plot has no xlabel or axis

2019-02-16 08:56发布

问题:

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')

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:

回答1:

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.



回答2:

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)