<h2 dir="auto">Problem</h2>
<p dir="auto">When executing the following snippet of code on matplolib 1.3.1, the month name November will show up twice on plot_date using a timezone with daylight saving time (meaning the second november tick is november 30, 23:00, almost december, but not quite). This is misleading and annoying when interpreting the plot because events after the december tick are already in january.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt

import pytz
import datetime
from dateutil.rrule import rrule, MONTHLY

mytz = pytz.timezone('America/Los_Angeles')

startdt = datetime.datetime(2013, 8, 1, 0, 0) # start during DST period 

# create positions where monthly ticks should be
myrule = rrule(MONTHLY, dtstart = startdt, count = 6)

localizer = lambda dt: mytz.localize(dt)
localized = [localizer(el) for el in myrule] # convert naive to timezone

plt.plot_date(localized, [1 for el in localized], '+-') # shows month name November twice
plt.grid(color = 'k', which = 'major', linestyle = ':', linewidth = 0.5)
plt.tight_layout()

plt.show()"><pre class="notranslate"><code class="notranslate"># -*- coding: utf-8 -*-

import matplotlib.pyplot as plt

import pytz
import datetime
from dateutil.rrule import rrule, MONTHLY

mytz = pytz.timezone('America/Los_Angeles')

startdt = datetime.datetime(2013, 8, 1, 0, 0) # start during DST period 

# create positions where monthly ticks should be
myrule = rrule(MONTHLY, dtstart = startdt, count = 6)

localizer = lambda dt: mytz.localize(dt)
localized = [localizer(el) for el in myrule] # convert naive to timezone

plt.plot_date(localized, [1 for el in localized], '+-') # shows month name November twice
plt.grid(color = 'k', which = 'major', linestyle = ':', linewidth = 0.5)
plt.tight_layout()

plt.show()
</code></pre></div>
<h2 dir="auto">Reason</h2>
<p dir="auto">In the example above, the proper tick positions are produced when using a naive datetime as startdt.</p>
<p dir="auto">The reason is presumably that dateutil.rrule results in "wrong" dates used as tick locations when startdt is already localized and normalized afterwards. When doing something in the line of</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="myrule = rrule(MONTHLY, dtstart = mytz.localize(startdt), count = 6)
print [mytz.normalize(dt) for dt in myrule]"><pre class="notranslate"><code class="notranslate">myrule = rrule(MONTHLY, dtstart = mytz.localize(startdt), count = 6)
print [mytz.normalize(dt) for dt in myrule]
</code></pre></div>
<p dir="auto">the datetimes from November onward will be off by the DST offset (which is not what I would like to have for the ticks position).</p>
<p dir="auto">Could this probably also happen in matplotlib?</p>
<h3 dir="auto">Problem</h3>
<p dir="auto">To implement scale change on an y-axis I use the axis itself as a button via <code class="notranslate">ax.yaxis.set_picker(true)</code>.<br>
Now, unexpectantly, it turns out that both yaxis's are responsive (and not only the left yaxis that seems the active one because of the labels and ticks). Also there seems to be no handle for distinguishing between the left or right yaxis.</p>
<p dir="auto">This leads to unexpected scale-changes, that is unintended click-effects when nearby the right yaxis other responsive elements are placed but the yaxis happens to catch the mousepress intended for any of those elements.</p>
<p dir="auto">For a consistent user-interface experience in this case, the duplicated yaxis interactivity is not helpful. Alternatives, say the y-label itself as button or the built-in scale-change functionality are not applicable (for reasons how the figure is set up ).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.axis import YAxis,XAxis

  def onpick(pevent): #PickEvent
        print(pevent.artist)
       if isinstance(pevent.artist,YAxis):
              print(pevent.artist.majorTicks)
              print(pevent.artist.label)
              print(pevent.artist.get_majorticklabels())
              print(pevent.artist.get_ticks_position())   # only gives 'left', the rcparam setting; not 
              print(pevent.artist.axes.get_ybound())
              pevent.artist.axes.set_ylabel('y clicked')
      if isinstance(pevent.artist,XAxis):
              pevent.artist.axes.set_ylabel('x clicked')
      fig.canvas.draw_idle()


   x = np.linspace(0, 2, 100)  # Sample data.

  # Note that even in the OO-style, we use `.pyplot.figure` to create the Figure.
  fig, ax = plt.subplots(figsize=(5, 2.7), layout='constrained')
  ax.plot(x, x, label='linear')  # Plot some data on the axes.
  ax.plot(x, x**2, label='quadratic')  # Plot more data on the axes...
  ax.plot(x, x**3, label='cubic')  # ... and some more.
  ax.set_xlabel('x label')  # Add an x-label to the axes.
  ax.set_ylabel('y label')  # Add a y-label to the axes.
  #ax.set_title(&quot;Simple Plot&quot;)  # Add a title to the axes.
  ax.yaxis.set_picker(True)
  ax.xaxis.set_picker(True)
  fig.canvas.mpl_connect('pick_event', onpick)
  ax.legend()  # Add a legend.

  plt.show()"><pre class="notranslate"><code class="notranslate">  import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.axis import YAxis,XAxis

  def onpick(pevent): #PickEvent
        print(pevent.artist)
       if isinstance(pevent.artist,YAxis):
              print(pevent.artist.majorTicks)
              print(pevent.artist.label)
              print(pevent.artist.get_majorticklabels())
              print(pevent.artist.get_ticks_position())   # only gives 'left', the rcparam setting; not 
              print(pevent.artist.axes.get_ybound())
              pevent.artist.axes.set_ylabel('y clicked')
      if isinstance(pevent.artist,XAxis):
              pevent.artist.axes.set_ylabel('x clicked')
      fig.canvas.draw_idle()


   x = np.linspace(0, 2, 100)  # Sample data.

  # Note that even in the OO-style, we use `.pyplot.figure` to create the Figure.
  fig, ax = plt.subplots(figsize=(5, 2.7), layout='constrained')
  ax.plot(x, x, label='linear')  # Plot some data on the axes.
  ax.plot(x, x**2, label='quadratic')  # Plot more data on the axes...
  ax.plot(x, x**3, label='cubic')  # ... and some more.
  ax.set_xlabel('x label')  # Add an x-label to the axes.
  ax.set_ylabel('y label')  # Add a y-label to the axes.
  #ax.set_title("Simple Plot")  # Add a title to the axes.
  ax.yaxis.set_picker(True)
  ax.xaxis.set_picker(True)
  fig.canvas.mpl_connect('pick_event', onpick)
  ax.legend()  # Add a legend.

  plt.show()
</code></pre></div>
<p dir="auto">Is there a way to check which of the two yaxis's has been clicked? I looked around but could not find anything. If not, maybe below suggestion might be valid.</p>
<h3 dir="auto">Proposed solution</h3>
<p dir="auto">The placement of the ticks and labels on the left or the right axis is governed by rcparams like <code class="notranslate">ytick.left: True</code>.</p>
<p dir="auto">Maybe a similar approach is easy to implement that could help to define which yaxis is reponsive (i.e. gets the picker-activity), say with a rcparam <code class="notranslate">yaxis.picker.left: True; yaxis.picker.right: False; </code> in the matplotlibrc.</p>
<p dir="auto">For the xaxis comparable additions <code class="notranslate">xaxis.picker.top: True; xaxis.picker.bottom: False; </code> would be relevant too.</p>