Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Plot_date default date format is not always the same #9765

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
mirkocoric opened this issue Nov 13, 2017 · 3 comments
Closed

Plot_date default date format is not always the same #9765

mirkocoric opened this issue Nov 13, 2017 · 3 comments

Comments

@mirkocoric
Copy link

Bug report

Bug summary

In the example below date format is changed when plotting with plot_date after calling dates.DayLocator(). This can be fixed with using dates.DateFormatter(), but the confusion could be avoided if plot_date uses the same date format when it is not specified by user.

Code for reproduction

import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

DATE1 = mdates.date2num(datetime.datetime(2017, 8, 10, 18, 0))
DATE2 = mdates.date2num(datetime.datetime(2017, 8, 11, 18, 0))
DATE3 = mdates.date2num(datetime.datetime(2017, 8, 12, 18, 0))
plt.plot_date([DATE1, DATE2, DATE3], [1, 2, 3], '-')
plt.show()

plt.plot_date([DATE1, DATE2, DATE3], [1, 2, 3], '-')
plt.gca().xaxis.set_major_locator(mdates.DayLocator())
plt.show()

Actual outcome

beforedaylocator

afterdaylocator

Matplotlib version

  • Operating system: Mac OS
  • Matplotlib version: 2.0.2
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version: 2.7.13
  • Jupyter version (if applicable):
  • Other libraries:
@story645
Copy link
Member

I sort of thing this should be generalized to plot_date should default to include the resolution of the ticks (or at least only one level higher). Like since it's a day locator, the ticks should include the days, it it was a month locator, it should id the months, etc...

@jklymak
Copy link
Member

jklymak commented Mar 24, 2018

Cross ref #10841

@timhoffm
Copy link
Member

Apparently fixed. As of current master, the ticks include the days.

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

No branches or pull requests

5 participants