Skip to content

BUG: hidden ticklabels with sharex and secondary #9164

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

Closed

Conversation

TomAugspurger
Copy link
Contributor

Closes #9158

import pandas as pd
d = {'A' : [1., 2., 3., 4.], 'B' : [4., 3., 2., 1.], 'C': [5, 1, 3, 4]}
df = pd.DataFrame(d, index=pd.date_range('2014 10 11', '2014 10 14'))

axes = df[['A','B']].plot(subplots=True)
df['C'].plot(ax=axes[0], secondary_y=True)   # x tick labels dissappear when this line is executed

gh

Introduced in the subplot refactoring in #7457

cc @sinhrks

The fix is pretty simple, but I'm worried I may have broken other things. No tests failed though, so hopefully we're good.

@TomAugspurger
Copy link
Contributor Author

My reformatting hides the change.

The only difference is in the call to _handle_shared_axes, naxes is now nrows * ncols, instead of len(all_axes). The problem was that all_axes is 3 now, since there's the original two subplots and the additional 3rd plot, which is getting plotted on the first subplot. This confused _handle_shared_axes.

@jreback jreback added the Visualization plotting label Jan 2, 2015
@jreback jreback added this to the 0.16.0 milestone Jan 2, 2015



- Bug in hiding ticklabels with subplots and shared axes when adding a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no spaces needed on multiple lines (it will auto-wrap)

@jreback
Copy link
Contributor

jreback commented Jan 2, 2015

looks good. minor doc issue.

@jreback
Copy link
Contributor

jreback commented Jan 18, 2015

@TomAugspurger looks ok, pls rebase.

@jreback jreback modified the milestones: 0.16.1, 0.16.0 Mar 5, 2015
@jreback
Copy link
Contributor

jreback commented Mar 5, 2015

needs a rebase

@TomAugspurger TomAugspurger force-pushed the sharex-secondary-ticks branch from 6e1e4aa to 63ae3bd Compare April 18, 2015 17:49
@TomAugspurger
Copy link
Contributor Author

Rebased... will merged later today.

@TomAugspurger
Copy link
Contributor Author

The failure here was a build failure on a job that doesn't run the plotting code. Going to merge

@TomAugspurger
Copy link
Contributor Author

Well, I messed that up. Pushed before --continuing my rebase, and it looks like github has it's done with this PR

@shadowleaves
Copy link

this problem seems to be still existing in pandas 0.17.0, on subplots with at least two rows:

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt

mat = np.random.rand(10,2)
df = pd.DataFrame(mat, columns=['A','B'])

fig, axes = plt.subplots(nrows=2, ncols=2)                                 
df.plot(secondary_y='B', ax=axes[0, 1], legend=False)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x tick labels not shown when using secondary_y=True on figure with multiple subplots
3 participants