You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading Matplotlib to 2.1.0 I had several plot having issue with Time Axis and Formatter.
I already know that Matplotlib does work well with np.datetime64 and works as expected with datetime.datetime. I know that I can use to_pydatetime() to convert index before plotting.
But here, I am facing a different thing, if I run a plot from Matplotlib it gives me result.
If I plot something else using pandas.DataFrame.plot, then next plot using Matplotlib behaves differently.
In the example above, we see:
First plot has a float axis without Date Formatter, xticks are negative float;
Second plot is time formatted by Pandas, xticks are negative integer;
Third plot, same code as first, axis is time formatted by Matplotlib and xticks are positive rounded float.
My conclusion is calling DataFrame.plot() modify Matplotlib behaviour.
Expected Output
I expected both Matplotlib code to render equal, but it does not.
It seems Matplotlib time conventions and representation change after calling Pandas plot.
I do not have enough insight in Pandas to understand what is going on behind. Is this normal?
Why does it happen? Is this a Pandas related problem or must I look to the Matplotlib side?
First plot has a float axis without Date Formatter, xticks are negative float;
This is as expected. Matplotlib cannot yet handle datetime64 data, so those timestamps are just converted to its underlying integer representation. But, the upcoming feature release of matplotlib should fix this.
Second plot is time formatted by Pandas, xticks are negative integer;
That is just the internals of the plotting machinery, this is correct (matplotlib plotting only deals with floats in the end, so everything has to be converted to floats)
Third plot, same code as first, axis is time formatted by Matplotlib and xticks are positive rounded float.
Yes, pandas plotting currently modified matplotlib behaviour. This will still be the case in 0.21.1, but we are exploring to fix this in pandas 0.22.0
Uh oh!
There was an error while loading. Please reload this page.
Code Sample, a copy-pastable example if possible
Problem description
After upgrading Matplotlib to 2.1.0 I had several plot having issue with Time Axis and Formatter.
I already know that Matplotlib does work well with
np.datetime64
and works as expected withdatetime.datetime
. I know that I can useto_pydatetime()
to convert index before plotting.But here, I am facing a different thing, if I run a plot from Matplotlib it gives me result.
If I plot something else using
pandas.DataFrame.plot
, then next plot using Matplotlib behaves differently.In the example above, we see:
xticks
are negativefloat
;xticks
are negativeinteger
;xticks
are positive roundedfloat
.My conclusion is calling
DataFrame.plot()
modify Matplotlib behaviour.Expected Output
I expected both Matplotlib code to render equal, but it does not.
It seems Matplotlib time conventions and representation change after calling Pandas
plot
.I do not have enough insight in Pandas to understand what is going on behind. Is this normal?
Why does it happen? Is this a Pandas related problem or must I look to the Matplotlib side?
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: