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
Non-aligned x-axes when plotting two series on the same axes #6630
Comments
Made this work by substituting my third line with:
but I should not have to do that, right? |
So it looks like for
They decided to set the default for this one to 1 (maybe so the boxes aren't draw outside the figure? I have real idea why...). I think something like >>> estimates.T.boxplot(ax=ax, grid=False, rot=90,
positions=range(len(estimates.T.columns)))
>>> axes.plot(counts) should work for you. Thoughts on whether this is something we should change in pandas? I tend towards honoring matplotlib's defaults / parameter names, even if they seem odd at first. |
I've also tried using the
|
I think I had the same problem when I was playing with it a few days ago. This one is a bug I think. What's happening is that You'll want to do |
@TomAugspurger this is marked as a good first issue, but I'm not sure if that's still the case. If so, I'd like to look into it. With the following minimal example (pandas v0.25.2 and matplotlib v3.1.1): import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
np.random.seed(0)
dates = pd.date_range('2019-01-01', '2019-01-07')
y = pd.DataFrame(np.random.randn(len(dates), 10), index=dates)
x = y.T.median() the most intuitive approach raises fig, ax = plt.subplots()
y.T.boxplot(ax=ax, rot=90)
x.plot(ax=ax) Reversing the order of y.T.boxplot(ax=ax, rot=90)
ax.plot(x)
y.T.boxplot(ax=ax, rot=90, positions=range(len(y.T.columns)))
x.plot(ax=ax) The only working approach is as suggested by @fonnesbeck: y.T.boxplot(ax=ax, rot=90)
ax.plot(ax.get_xticks(), x) |
I have the following
DataFrame
that I want to create a boxplot for:along with a
Series
that I want to plot on the same axes:They are both the same length, and have the same index (in fact, to ensure the latter, I assigned the index
estimates
tocounts
). However, when I plot them on the same set of axes, the plot for thecounts
is off by one on the x-axis:Notice in the plot the line graph does not begin with zero at 2009-04-28 as is clearly shown in the data, and you can see the entire line is shifted. This looks like an alignment error, no?
The text was updated successfully, but these errors were encountered: