Issue 1:
Problem

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.

# -*- 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()

Reason

In the example above, the proper tick positions are produced when using a naive datetime as startdt.

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

myrule = rrule(MONTHLY, dtstart = mytz.localize(startdt), count = 6)
print [mytz.normalize(dt) for dt in myrule]

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).

Could this probably also happen in matplotlib?

Issue 2:
Problem

To implement scale change on an y-axis I use the axis itself as a button via ax.yaxis.set_picker(true).

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.

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.

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 ).

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()

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.

Proposed solution

The placement of the ticks and labels on the left or the right axis is governed by rcparams like ytick.left: True.

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 yaxis.picker.left: True; yaxis.picker.right: False; in the matplotlibrc.

For the xaxis comparable additions xaxis.picker.top: True; xaxis.picker.bottom: False; would be relevant too.