-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

I just created my first patch for matplotlib, it's addressing bug 3176823.

I send the patch with an example (as suggested in the faq).

You can see the effect in the example: before patching it ignores the tz
argument, and marks are set at 23:00. The example dates are at 23:00
o'clock in utc, but should be displayed as 0:00, because the exmaple
"lives" in timezone Europe/Berlin.

Hopefully i got this converter stuff right, i changed in
dates.DateConverter:

 def default_units(x, axis):
         'Return the default unit for *x* or None'
- -        return None
+        return x

and in axis.py i did


- -    def axis_date(self):
+    def axis_date(self, tz):
         """
         Sets up x-axis ticks and labels that treat the x data as dates.
+        *tz* is the time zone to use in labeling dates.
         """
         import datetime
         # should be enough to inform the unit conversion interface
         # dates are comng in
- -        self.update_units(datetime.date(2009,1,1))
+        self.update_units(tz.localize(datetime.datetime(2009,1,1)))

so that now DateConverter.axisinfo can now something about timezones:

    def axisinfo(unit, axis):
        'return the unit AxisInfo'
         # make sure that the axis does not start at 0

- -        majloc = AutoDateLocator(tz=unit)
- -        majfmt = AutoDateFormatter(majloc, tz=unit)
+        tz = None
+        if getattr(unit, "tzinfo", None):
+            tz = unit.tzinfo
+
+        majloc = AutoDateLocator(tz=tz)
+        majfmt = AutoDateFormatter(majloc, tz=tz)


cheers,
Maximilian

PS: sry, im not that used to writing mails in english
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNXBWoAAoJEMxyzzlQGYxT/IwH/jyLsd5ldmzFUTjmV0qIaDdu
ct1B0/FbpGf2/F6+IyQxEoltYUXNpWwf4fzg/bdjBAd4CHaS1S0tOv7o6m9JHZDe
J6Eym9h1DmXVPkLJau4gdi1jZwTMpP94ac8wcHDqP39rXSiC/klRdXqpizccD2eP
9DbmgnePd61UQCYJchg9fBwIfSJg1iC7wpGuC51uLkyLT1P1ITDXbvSFH82zWtDU
hBCc8w54X7wlsDuCSejnibocIj251YhyG3cXbWrdw0+wTg+8L9mxglAo+TmCI2Nb
aOIYlQUunhBQkVRIG2qTKXmu6CDv1Sk1u1oxnEGeVXxVsJIbdLWxEPBb1jOjjJI=
=zRMW
-----END PGP SIGNATURE-----
#coding: utf-8
import matplotlib
matplotlib.use("Qt4Agg")

import matplotlib.pyplot as pyplot
import matplotlib.dates as dates
import datetime
import pytz

utc = pytz.utc
berlin = pytz.timezone("Europe/Berlin")

mydates = [datetime.datetime(2011,1,i, 0, 0) for i in range(1,4)]  #assume these dates are in berlin-timezone
berlindates = [berlin.localize(d) for d in mydates]

pyplot.plot_date(dates.date2num(berlindates), [1,2,3], xdate=True, ydate=False, tz=berlin)
#workaround before patch, to tell the formatter about timezone
#pyplot.gca().get_xaxis().set_major_formatter(dates.DateFormatter("%H",tz=berlin))
pyplot.show()
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to