Skip to content

Create correct xlim for ts plot and update datetimelike tests #28021

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

Open
charlesdong1991 opened this issue Aug 19, 2019 · 7 comments
Open

Create correct xlim for ts plot and update datetimelike tests #28021

charlesdong1991 opened this issue Aug 19, 2019 · 7 comments
Labels

Comments

@charlesdong1991
Copy link
Member

charlesdong1991 commented Aug 19, 2019

xref: #27993

The view limit for non-datetime plotting is solved. and behavior will be the same as 0.23.4
e.g.
Screen Shot 2019-08-21 at 3 59 55 PM

HOWEVER, issue in datetime-like still exists:
The issue with datetime-like plotting, xlim will be changed, and the view limit is set to data limit, so there is no margin on xaxis. Plots are looking like:
Screen Shot 2019-08-21 at 3 07 17 PM

@TomAugspurger TomAugspurger added the Visualization plotting label Aug 20, 2019
@TomAugspurger
Copy link
Contributor

@charlesdong1991 I copied your comment from #27993 (comment) into the original issue. Hope that's OK.

Do you still have the actual code snippets, rather than the text? It'd be nice to have them around.

I do agree that the "after your change" behavior looks correct.

@charlesdong1991
Copy link
Member Author

charlesdong1991 commented Aug 20, 2019

ahh, thanks for editing, I should have done more on description. @TomAugspurger

what do you mean by actual code snippets? something like this? (this was basically copied from the actual tests from test_datetimelike.py)

yrs = [3.5, 11]

xpl1 = xpl2 = [pd.Period("1988Q1").ordinal] * len(yrs)
rs1 = []
rs2 = []
for i, n in enumerate(yrs):
    rng = pd.period_range("1987Q2", periods=int(n * 4), freq="Q")
    ser = pd.Series(np.random.randn(len(rng)), rng)
    _, ax = plt.subplots()
    ser.plot(ax=ax)
    xaxis = ax.get_xaxis()
    rs1.append(xaxis.get_majorticklocs()[0])

    (vmin, vmax) = ax.get_xlim()
    ax.set_xlim(vmin + 0.9, vmax)
    rs2.append(xaxis.get_majorticklocs()[0])

@charlesdong1991
Copy link
Member Author

and PR for this test is coming!

@charlesdong1991
Copy link
Member Author

charlesdong1991 commented Aug 21, 2019

i am sincerely apologizing for this, I realize today when doing tests that my fix is improper/wrong in terms of timeseries plotting. I am still trying to find root cause, hope to correct it asap before new release. Sorry again for it. @TomAugspurger
the issue/problem is when plotting datetime like, it will lose the pandas datetime formatter information on xaxis. if it's not datetime, then it will be fine.

@charlesdong1991 charlesdong1991 changed the title Update the finder tests in datetimelike file Create correct xlim for ts plot and update datetimelike tests Aug 21, 2019
@arthurire
Copy link

Just want to make sure if you have fixed this issue in 0.25.2, I can still reproduce this error in 0.25.2.
CleanShot 2019-10-31 at 10 39 30@2x

@charlesdong1991
Copy link
Member Author

Hi, thanks for your comment, @arthurire However, I could not reproduce it in master, this looks fine to me.

Screen Shot 2019-10-31 at 4 59 42 PM

@charlesdong1991
Copy link
Member Author

emm, unfortunately i have to take back my previous comment.

Just found out that this works as expected in my development setup, but if I import pandas in other environments/places, then I could reproduce this issue. Looks weird.

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 a pull request may close this issue.

4 participants