@@ -169,6 +169,9 @@ def dst(self, dt):
169
169
170
170
171
171
def _get_rc_timezone ():
172
+ """
173
+ Retrieve the preferred timeszone from the rcParams dictionary.
174
+ """
172
175
s = matplotlib .rcParams ['timezone' ]
173
176
if s == 'UTC' :
174
177
return UTC
@@ -247,7 +250,8 @@ def _from_ordinalf(x, tz=None):
247
250
dt = datetime .datetime .fromordinal (ix )
248
251
remainder = float (x ) - ix
249
252
250
- dt += datetime .timedelta (seconds = remainder * SEC_PER_DAY )
253
+ dt += datetime .timedelta (seconds = remainder * SEC_PER_DAY )
254
+ dt = dt .astimezone (tz )
251
255
252
256
return dt
253
257
@@ -752,20 +756,20 @@ def _get_unit(self):
752
756
753
757
@staticmethod
754
758
def get_unit_generic (freq ):
755
- if ( freq == YEARLY ) :
759
+ if freq == YEARLY :
756
760
return DAYS_PER_YEAR
757
- elif ( freq == MONTHLY ) :
761
+ elif freq == MONTHLY :
758
762
return DAYS_PER_MONTH
759
- elif ( freq == WEEKLY ) :
763
+ elif freq == WEEKLY :
760
764
return DAYS_PER_WEEK
761
- elif ( freq == DAILY ) :
765
+ elif freq == DAILY :
762
766
return 1.0
763
- elif ( freq == HOURLY ) :
764
- return ( 1.0 / HOURS_PER_DAY )
765
- elif ( freq == MINUTELY ) :
766
- return ( 1.0 / MINUTES_PER_DAY )
767
- elif ( freq == SECONDLY ) :
768
- return ( 1.0 / SEC_PER_DAY )
767
+ elif freq == HOURLY :
768
+ return 1.0 / HOURS_PER_DAY
769
+ elif freq == MINUTELY :
770
+ return 1.0 / MINUTES_PER_DAY
771
+ elif freq == SECONDLY :
772
+ return 1.0 / SEC_PER_DAY
769
773
else :
770
774
# error
771
775
return - 1 # or should this just return '1'?
@@ -1083,7 +1087,7 @@ class MonthLocator(RRuleLocator):
1083
1087
"""
1084
1088
Make ticks on occurances of each month month, eg 1, 3, 12.
1085
1089
"""
1086
- def __init__ (self , bymonth = None , bymonthday = 1 , interval = 1 , tz = None ):
1090
+ def __init__ (self , bymonth = None , bymonthday = 1 , interval = 1 , tz = None ):
1087
1091
"""
1088
1092
Mark every month in *bymonth*; *bymonth* can be an int or
1089
1093
sequence. Default is ``range(1,13)``, i.e. every month.
@@ -1103,7 +1107,7 @@ class WeekdayLocator(RRuleLocator):
1103
1107
Make ticks on occurances of each weekday.
1104
1108
"""
1105
1109
1106
- def __init__ (self , byweekday = 1 , interval = 1 , tz = None ):
1110
+ def __init__ (self , byweekday = 1 , interval = 1 , tz = None ):
1107
1111
"""
1108
1112
Mark every weekday in *byweekday*; *byweekday* can be a number or
1109
1113
sequence.
@@ -1125,7 +1129,7 @@ class DayLocator(RRuleLocator):
1125
1129
Make ticks on occurances of each day of the month. For example,
1126
1130
1, 15, 30.
1127
1131
"""
1128
- def __init__ (self , bymonthday = None , interval = 1 , tz = None ):
1132
+ def __init__ (self , bymonthday = None , interval = 1 , tz = None ):
1129
1133
"""
1130
1134
Mark every day in *bymonthday*; *bymonthday* can be an int or
1131
1135
sequence.
@@ -1143,7 +1147,7 @@ class HourLocator(RRuleLocator):
1143
1147
"""
1144
1148
Make ticks on occurances of each hour.
1145
1149
"""
1146
- def __init__ (self , byhour = None , interval = 1 , tz = None ):
1150
+ def __init__ (self , byhour = None , interval = 1 , tz = None ):
1147
1151
"""
1148
1152
Mark every hour in *byhour*; *byhour* can be an int or sequence.
1149
1153
Default is to tick every hour: ``byhour=range(24)``
@@ -1162,7 +1166,7 @@ class MinuteLocator(RRuleLocator):
1162
1166
"""
1163
1167
Make ticks on occurances of each minute.
1164
1168
"""
1165
- def __init__ (self , byminute = None , interval = 1 , tz = None ):
1169
+ def __init__ (self , byminute = None , interval = 1 , tz = None ):
1166
1170
"""
1167
1171
Mark every minute in *byminute*; *byminute* can be an int or
1168
1172
sequence. Default is to tick every minute: ``byminute=range(60)``
@@ -1181,7 +1185,7 @@ class SecondLocator(RRuleLocator):
1181
1185
"""
1182
1186
Make ticks on occurances of each second.
1183
1187
"""
1184
- def __init__ (self , bysecond = None , interval = 1 , tz = None ):
1188
+ def __init__ (self , bysecond = None , interval = 1 , tz = None ):
1185
1189
"""
1186
1190
Mark every second in *bysecond*; *bysecond* can be an int or
1187
1191
sequence. Default is to tick every second: ``bysecond = range(60)``
@@ -1252,7 +1256,7 @@ def _close_to_dt(d1, d2, epsilon=5):
1252
1256
delta = d2 - d1
1253
1257
mus = abs (delta .days * MUSECONDS_PER_DAY + delta .seconds * 1e6 +
1254
1258
delta .microseconds )
1255
- assert ( mus < epsilon )
1259
+ assert mus < epsilon
1256
1260
1257
1261
1258
1262
def _close_to_num (o1 , o2 , epsilon = 5 ):
@@ -1261,7 +1265,7 @@ def _close_to_num(o1, o2, epsilon=5):
1261
1265
microseconds.
1262
1266
"""
1263
1267
delta = abs ((o2 - o1 ) * MUSECONDS_PER_DAY )
1264
- assert ( delta < epsilon )
1268
+ assert delta < epsilon
1265
1269
1266
1270
1267
1271
def epoch2num (e ):
@@ -1304,10 +1308,10 @@ def date_ticker_factory(span, tz=None, numticks=5):
1304
1308
if span == 0 :
1305
1309
span = 1 / HOURS_PER_DAY
1306
1310
1307
- minutes = span * MINUTES_PER_DAY
1308
- hours = span * HOURS_PER_DAY
1311
+ mins = span * MINUTES_PER_DAY
1312
+ hrs = span * HOURS_PER_DAY
1309
1313
days = span
1310
- weeks = span / DAYS_PER_WEEK
1314
+ wks = span / DAYS_PER_WEEK
1311
1315
months = span / DAYS_PER_MONTH # Approx
1312
1316
years = span / DAYS_PER_YEAR # Approx
1313
1317
@@ -1317,17 +1321,17 @@ def date_ticker_factory(span, tz=None, numticks=5):
1317
1321
elif months > numticks :
1318
1322
locator = MonthLocator (tz = tz )
1319
1323
fmt = '%b %Y'
1320
- elif weeks > numticks :
1324
+ elif wks > numticks :
1321
1325
locator = WeekdayLocator (tz = tz )
1322
1326
fmt = '%a, %b %d'
1323
1327
elif days > numticks :
1324
1328
locator = DayLocator (interval = int (math .ceil (days / numticks )), tz = tz )
1325
1329
fmt = '%b %d'
1326
- elif hours > numticks :
1327
- locator = HourLocator (interval = int (math .ceil (hours / numticks )), tz = tz )
1330
+ elif hrs > numticks :
1331
+ locator = HourLocator (interval = int (math .ceil (hrs / numticks )), tz = tz )
1328
1332
fmt = '%H:%M\n %b %d'
1329
- elif minutes > numticks :
1330
- locator = MinuteLocator (interval = int (math .ceil (minutes / numticks )),
1333
+ elif mins > numticks :
1334
+ locator = MinuteLocator (interval = int (math .ceil (mins / numticks )),
1331
1335
tz = tz )
1332
1336
fmt = '%H:%M:%S'
1333
1337
else :
0 commit comments