From 73affe14f55816545767a37035bf9bcfced905bc Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 8 Mar 2019 11:33:49 +0100 Subject: [PATCH 1/2] Clarify tick collision API change doc. --- doc/api/next_api_changes/2018-01-30-AL.rst | 40 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/api/next_api_changes/2018-01-30-AL.rst b/doc/api/next_api_changes/2018-01-30-AL.rst index 512cdbfbc764..2e19298de291 100644 --- a/doc/api/next_api_changes/2018-01-30-AL.rst +++ b/doc/api/next_api_changes/2018-01-30-AL.rst @@ -1,10 +1,40 @@ -Minor Locator no longer try to avoid overstriking major Locators -```````````````````````````````````````````````````````````````` +Minor ticks that collide with major ticks are always hidden +``````````````````````````````````````````````````````````` Previously, certain locator classes (`LogLocator`, `AutoMinorLocator`) contained custom logic to avoid emitting tick locations that collided with major ticks when they were used as minor locators. -This logic has now moved to the Axis class; thus, for example, -``xaxis.minor.locator()`` now includes positions that collide with -``xaxis.major.locator()``, but ``xaxis.get_minorticklocs()`` does not. +This logic has now moved to the Axis class, and is used *regardless of the +ticker class*. ``xaxis.minor.locator()`` now includes positions that collide +with ``xaxis.major.locator()``, but ``xaxis.get_minorticklocs()`` does not. + +If you were relying on both the major and minor tick labels to appear on the +same tick, you may need to update your code. For example, the following +snippet labeled days using major ticks and hours and minutes using minor +ticks:: + + import numpy as np + import matplotlib.dates as mdates + import matplotlib.pyplot as plt + + t = np.arange("2018-11-03", "2018-11-06", dtype="datetime64") + x = np.random.rand(len(t)) + + fig, ax = plt.subplots() + ax.plot(t, x) + ax.xaxis.set( + major_locator=mdates.DayLocator(), + major_formatter=mdates.DateFormatter("\n%a"), + minor_locator=mdates.HourLocator((0, 6, 12, 18)), + minor_formatter=mdates.DateFormatter("%H:%M"), + ) + + plt.show() + +and added a newline to the major ticks labels to avoid them crashing into the +minor tick labels. + +With the API change, the major tick labels should also include hours and +minutes, as the minor ticks are gone, so the ``major_formatter`` should be +``mdates.DateFormatter("%H:%M\n%a")``. From 49a7974e27a4d47fb610f0209a949a29bddd962f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 8 Mar 2019 12:00:00 +0100 Subject: [PATCH 2/2] Update doc/api/next_api_changes/2018-01-30-AL.rst Co-Authored-By: anntzer --- doc/api/next_api_changes/2018-01-30-AL.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/2018-01-30-AL.rst b/doc/api/next_api_changes/2018-01-30-AL.rst index 2e19298de291..6b9479f6db49 100644 --- a/doc/api/next_api_changes/2018-01-30-AL.rst +++ b/doc/api/next_api_changes/2018-01-30-AL.rst @@ -11,7 +11,7 @@ with ``xaxis.major.locator()``, but ``xaxis.get_minorticklocs()`` does not. If you were relying on both the major and minor tick labels to appear on the same tick, you may need to update your code. For example, the following -snippet labeled days using major ticks and hours and minutes using minor +snippet labeled days using major ticks, and hours and minutes using minor ticks:: import numpy as np