Matplotlib plot_date changed the zero point of the dates in >v3.3
See original GitHub issueDescription
astropy.time.TimePlotDate
returns Matplotlib plot_date input: 1 + number of days from 0001-01-01 00:00:00 UTC
But Matplotlib changed the date from which they count in plot_date function to 1970-01-01 UTC since Matplotlib v3.3
See the note here: https://matplotlib.org/api/dates_api.html#matplotlib-date-format
Expected behavior
import matplotlib.pyplot as plt
from astropy.time import Time
import numpy as np
jyear = np.linspace(2000, 2001, 20)
t = Time(jyear, format='jyear', scale='utc')
plt.plot_date(t.plot_date, jyear)
plt.show()
Should plot dates 2000 to 2001
Actual behavior
Instead, resulted in a plot showing dates from the year 3969 to 3970
Steps to Reproduce
- Install lastest version of astropy and matplotlib
- Try the code snippet below
import matplotlib.pyplot as plt
from astropy.time import Time
import numpy as np
jyear = np.linspace(2000, 2001, 20)
t = Time(jyear, format='jyear', scale='utc')
plt.plot_date(t.plot_date, jyear)
plt.show()
System Details
Linux-3.10.0-957.1.3.el7.x86_64-x86_64-with-centos-7.6.1810-Core Python 3.6.6 (default, Aug 13 2018, 18:24:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] Numpy 1.17.3 astropy 4.1 Scipy 1.5.2 Matplotlib 3.3.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (12 by maintainers)
Top Results From Across the Web
Fixing common date annoyances - Matplotlib
To fix the first problem, we can use Figure.autofmt_xdate and to fix the second problem we can use the ax.fmt_xdata attribute which can...
Read more >How to change the datetime tick label frequency for matplotlib ...
plot chooses dates that are approximately 3 months apart as ticks. But what I want is each month being a tick. What is...
Read more >matplotlib.pyplot.plot_date() in Python - GeeksforGeeks
The plot_date() function in pyplot module of matplotlib library is used to plot with data that contains dates. Syntax:
Read more >Time and Dates (astropy.time) — Astropy v5.2
Floating point algorithms from 1 are used so that the Time object maintains ... 1, 2, 1, 2, 3)) >>> t.format 'datetime' >>>...
Read more >What's New In Python 3.9 — Python 3.11.1 documentation
When Python 2.7 was still supported, a lot of functionality in Python 3 was kept for ... from zoneinfo import ZoneInfo >>> from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh…okay… no problem. I shall update to python 3.7 or later
I’m going to close this issue as per my previous message, but if you feel that this issue should stay open, then feel free to re-open and remove the Close? label.
If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here