Skip to content
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

Plotting using subplots #3964

michaelaye opened this issue Jun 19, 2013 · 3 comments


None yet
4 participants
Copy link

commented Jun 19, 2013

I am creating the attached plot like this:

fig, axes = subplots(3,3, sharex=True, sharey=True)
for ch in range(1,7):
    axis = axes.flatten()[ch-1]
    cols = some code to map ch to col_names
# do the same for 3 more channels with different IDs
for ch in range(1,4):
    axis = axes.flatten()[ch-1+6]
    cols = some code to map ch to col_names, slightly different to above

I have 2 problems with the result:

  1. sharex does not seem to work for time axes
  2. The last major x-ticklabel of the last row of axes is 10:00, while for the first 2 rows it is 9:00. I confirmed that all columns have data in the last row (index = 2011-04-02 10:00:00.718000) and not NaN which would have been excluded in the plot, potentially.

Possibly the 2 probs are related?


@jreback jreback modified the milestones: 0.15.0, 0.14.0 Feb 18, 2014


This comment has been minimized.

Copy link

commented Jul 20, 2014

Not 100% sure, but this seems to be the same issue as #7801. Based on my understanding:

  1. sharex works correctly.
  2. ticklabels looks different because major ticklabels are displayed only on bottom axes.

Unfortunately #7801 CANNOT solve this because #7801 will hide minor ticklabels in, and will not affect existing axes created by plt.subplots.

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

fig, axes = plt.subplots(3, 3, sharex=True)
plt.subplots_adjust(left=0.05, right=0.95, hspace=0.3, wspace=0.3)
df = pd.DataFrame(np.random.randn(10, 9), index=pd.date_range(start='2014-07-01', freq='M', periods=10))
for i, ax in enumerate(axes.ravel()):
    df[i].plot(ax=ax, fontsize=5)


Workaround is use layout kw to create (3, 3) layout using (possible after #7736).


This comment has been minimized.

Copy link
Contributor Author

commented Jul 21, 2014

I don't understand what you are saying, because the idea of sharex is that only the bottom line of graphs shows the x-axis' labels, so why would you state above that sharex is working correctly?


This comment has been minimized.

Copy link

commented Dec 7, 2014

Closed via #8764

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.