| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,28 @@ | |||
| 1 | 1 | New rcParams for dates: set converter and whether to use interval_multiples | |
| 2 | 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 3 | 3 | ||
| 4 | - The new :rc:`dates.converter` allows toggling between | ||
| 4 | + The new :rc:`date.converter` allows toggling between | ||
| 5 | 5 | `matplotlib.dates.DateConverter` and `matplotlib.dates.ConciseDateConverter` | |
| 6 | 6 | using the strings 'auto' and 'concise' respectively. | |
| 7 | 7 | ||
| 8 | - The new :rc:`dates.interval_multiples` allows toggling between the dates | ||
| 8 | + The new :rc:`date.interval_multiples` allows toggling between the dates | ||
| 9 | 9 | locator trying to pick ticks at set intervals (i.e. day 1 and 15 of the | |
| 10 | 10 | month), versus evenly spaced ticks that start where ever the | |
| 11 | - timeseries starts. | ||
| 11 | + timeseries starts:: | ||
| 12 | + | ||
| 13 | + import matplotlib.pyplot as plt | ||
| 14 | + import numpy as np | ||
| 15 | + | ||
| 16 | + dates = np.arange('2001-01-10', '2001-05-23', dtype='datetime64[D]') | ||
| 17 | + y = np.sin(dates.astype(float) / 10) | ||
| 18 | + fig, axs = plt.subplots(nrows=2, constrained_layout=True) | ||
| 19 | + | ||
| 20 | + plt.rcParams['date.converter'] = 'concise' | ||
| 21 | + plt.rcParams['date.interval_multiples'] = True | ||
| 22 | + ax = axs[0] | ||
| 23 | + ax.plot(dates, y) | ||
| 24 | + | ||
| 25 | + plt.rcParams['date.converter'] = 'auto' | ||
| 26 | + plt.rcParams['date.interval_multiples'] = False | ||
| 27 | + ax = axs[1] | ||
| 28 | + ax.plot(dates, y) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1832,7 +1832,7 @@ class DateConverter(units.ConversionInterface): | |||
| 1832 | 1832 | The 'unit' tag for such data is None or a tzinfo instance. | |
| 1833 | 1833 | """ | |
| 1834 | 1834 | ||
| 1835 | - def __init__(self, interval_multiples=True): | ||
| 1835 | + def __init__(self, *, interval_multiples=True): | ||
| 1836 | 1836 | self._interval_multiples = interval_multiples | |
| 1837 | 1837 | super().__init__() | |
| 1838 | 1838 | ||
@@ -1888,7 +1888,7 @@ class ConciseDateConverter(DateConverter): | |||
| 1888 | 1888 | # docstring inherited | |
| 1889 | 1889 | ||
| 1890 | 1890 | def __init__(self, formats=None, zero_formats=None, offset_formats=None, | |
| 1891 | - show_offset=True, interval_multiples=True): | ||
| 1891 | + show_offset=True, *, interval_multiples=True): | ||
| 1892 | 1892 | self._formats = formats | |
| 1893 | 1893 | self._zero_formats = zero_formats | |
| 1894 | 1894 | self._offset_formats = offset_formats | |
| Back | FazBrowse Home | New Git URL |
0 commit comments