diff --git a/doc/api/next_api_changes/2018-07-02-JMK.rst b/doc/api/next_api_changes/2018-07-02-JMK.rst new file mode 100644 index 000000000000..20f591fbd69b --- /dev/null +++ b/doc/api/next_api_changes/2018-07-02-JMK.rst @@ -0,0 +1,37 @@ +Changed default `AutoDateLocator` kwarg ``interval_multiples`` to ``True`` +-------------------------------------------------------------------------- + +The default value of the tick locator for dates, `.dates.AutoDateLocator` +kwarg ``interval_multiples`` was set to ``False`` which leads to not-nice +looking automatic ticks in many instances. The much nicer +``interval_multiples=True`` is the new default. See below to get the +old behavior back: + + .. plot:: + + import matplotlib.pyplot as plt + import datetime + import matplotlib.dates as mdates + + t0 = datetime.datetime(2009, 8, 20, 1, 10, 12) + tf = datetime.datetime(2009, 8, 20, 1, 42, 11) + + + fig, axs = plt.subplots(1, 2, constrained_layout=True) + ax = axs[0] + ax.axhspan(t0, tf, facecolor="blue", alpha=0.25) + ax.set_ylim(t0 - datetime.timedelta(minutes=3), + tf + datetime.timedelta(minutes=3)) + ax.set_title('NEW DEFAULT') + + ax = axs[1] + ax.axhspan(t0, tf, facecolor="blue", alpha=0.25) + ax.set_ylim(t0 - datetime.timedelta(minutes=3), + tf + datetime.timedelta(minutes=3)) + # old behavior + locator = mdates.AutoDateLocator(interval_multiples=False, ) + ax.yaxis.set_major_locator(locator) + ax.yaxis.set_major_formatter(mdates.AutoDateFormatter(locator)) + + ax.set_title('OLD') + plt.show() diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 0af5f0f93807..71177a9eaaa0 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -1158,7 +1158,7 @@ class AutoDateLocator(DateLocator): locations. """ def __init__(self, tz=None, minticks=5, maxticks=None, - interval_multiples=False): + interval_multiples=True): """ *minticks* is the minimum number of ticks desired, which is used to select the type of ticking (yearly, monthly, etc.). @@ -1234,6 +1234,12 @@ def __init__(self, tz=None, minticks=5, maxticks=None, MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000]} + if interval_multiples: + # Swap "3" for "4" in the DAILY list; If we use 3 we get bad + # tick loc for months w/ 31 days: 1, 4,..., 28, 31, 1 + # If we use 4 then we get: 1, 5, ... 25, 29, 1 + self.intervald[DAILY] = [1, 2, 4, 7, 14, 21] + self._byranges = [None, range(1, 13), range(1, 32), range(0, 24), range(0, 60), range(0, 60), None] @@ -1338,7 +1344,11 @@ def get_locator(self, dmin, dmax): self._freq = freq if self._byranges[i] and self.interval_multiples: - byranges[i] = self._byranges[i][::interval] + if i == DAILY and interval == 14: + # just make first and 15th. Avoids 30th. + byranges[i] = [1, 15] + else: + byranges[i] = self._byranges[i][::interval] interval = 1 else: byranges[i] = self._byranges[i] diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pcolor_datetime_axis.png b/lib/matplotlib/tests/baseline_images/test_axes/pcolor_datetime_axis.png index c5901ad07c98..e91562470215 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/pcolor_datetime_axis.png and b/lib/matplotlib/tests/baseline_images/test_axes/pcolor_datetime_axis.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pcolormesh_datetime_axis.png b/lib/matplotlib/tests/baseline_images/test_axes/pcolormesh_datetime_axis.png index c5901ad07c98..e91562470215 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/pcolormesh_datetime_axis.png and b/lib/matplotlib/tests/baseline_images/test_axes/pcolormesh_datetime_axis.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/single_date.pdf b/lib/matplotlib/tests/baseline_images/test_axes/single_date.pdf deleted file mode 100644 index 35043f550854..000000000000 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/single_date.pdf and /dev/null differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/single_date.png b/lib/matplotlib/tests/baseline_images/test_axes/single_date.png index 08d8390448dd..9df3334340c2 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/single_date.png and b/lib/matplotlib/tests/baseline_images/test_axes/single_date.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/single_date.svg b/lib/matplotlib/tests/baseline_images/test_axes/single_date.svg deleted file mode 100644 index b6a1c013fc2b..000000000000 --- a/lib/matplotlib/tests/baseline_images/test_axes/single_date.svg +++ /dev/null @@ -1,1259 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/matplotlib/tests/baseline_images/test_contour/contour_datetime_axis.png b/lib/matplotlib/tests/baseline_images/test_contour/contour_datetime_axis.png index 91d04aa441e5..75b36281aa54 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_contour/contour_datetime_axis.png and b/lib/matplotlib/tests/baseline_images/test_contour/contour_datetime_axis.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png b/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png index 8077953f5a57..57c4ad763f37 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png and b/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png b/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png index 2b3faae7396c..f13d879e9f53 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png and b/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png b/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png index 856b6cab10a0..f6b19c37af88 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png and b/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_dates/date_inverted_limit.png b/lib/matplotlib/tests/baseline_images/test_dates/date_inverted_limit.png index 4e55706c55fd..4b8d15155717 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_dates/date_inverted_limit.png and b/lib/matplotlib/tests/baseline_images/test_dates/date_inverted_limit.png differ diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index fda0fe0f362b..e1788f26290f 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -551,7 +551,8 @@ def test_single_point(): plt.plot('b', 'b', 'o', data=data) -@image_comparison(baseline_images=['single_date']) +@image_comparison(baseline_images=['single_date'], extensions=['png'], + style='mpl20') def test_single_date(): time1 = [721964.0] data1 = [-65.54] @@ -1156,7 +1157,7 @@ def test_pcolormesh(): @image_comparison(baseline_images=['pcolormesh_datetime_axis'], - extensions=['png'], remove_text=False) + extensions=['png'], remove_text=False, style='mpl20') def test_pcolormesh_datetime_axis(): fig = plt.figure() fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15) @@ -1182,7 +1183,7 @@ def test_pcolormesh_datetime_axis(): @image_comparison(baseline_images=['pcolor_datetime_axis'], - extensions=['png'], remove_text=False) + extensions=['png'], remove_text=False, style='mpl20') def test_pcolor_datetime_axis(): fig = plt.figure() fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15) diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index 7c451ca16c77..9709a151a350 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -224,7 +224,7 @@ def test_given_colors_levels_and_extends(): @image_comparison(baseline_images=['contour_datetime_axis'], - extensions=['png'], remove_text=False) + extensions=['png'], remove_text=False, style='mpl20') def test_contour_datetime_axis(): fig = plt.figure() fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15) diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index e9b2e18c56f9..67b902f121a1 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -322,7 +322,7 @@ def test_empty_date_with_year_formatter(): def test_auto_date_locator(): def _create_auto_date_locator(date1, date2): - locator = mdates.AutoDateLocator() + locator = mdates.AutoDateLocator(interval_multiples=False) locator.create_dummy_axis() locator.set_view_interval(mdates.date2num(date1), mdates.date2num(date2)) @@ -423,10 +423,12 @@ def _create_auto_date_locator(date1, date2): '1997-05-01 00:00:00+00:00', '1997-05-22 00:00:00+00:00'] ], [datetime.timedelta(days=40), - ['1997-01-01 00:00:00+00:00', '1997-01-08 00:00:00+00:00', - '1997-01-15 00:00:00+00:00', '1997-01-22 00:00:00+00:00', - '1997-01-29 00:00:00+00:00', '1997-02-01 00:00:00+00:00', - '1997-02-08 00:00:00+00:00'] + ['1997-01-01 00:00:00+00:00', '1997-01-05 00:00:00+00:00', + '1997-01-09 00:00:00+00:00', '1997-01-13 00:00:00+00:00', + '1997-01-17 00:00:00+00:00', '1997-01-21 00:00:00+00:00', + '1997-01-25 00:00:00+00:00', '1997-01-29 00:00:00+00:00', + '1997-02-01 00:00:00+00:00', '1997-02-05 00:00:00+00:00', + '1997-02-09 00:00:00+00:00'] ], [datetime.timedelta(hours=40), ['1997-01-01 00:00:00+00:00', '1997-01-01 04:00:00+00:00', diff --git a/setup.cfg.template b/setup.cfg.template index 8d4669492afb..7ccfb7edcbe4 100644 --- a/setup.cfg.template +++ b/setup.cfg.template @@ -18,7 +18,7 @@ [status] # To suppress display of the dependencies and their versions # at the top of the build log, uncomment the following line: -#suppress = True +#suppress = True [packages] # There are a number of subpackages of Matplotlib that are considered