Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44afc73

Browse filesBrowse files
committed
Merge pull request #6091 from KyleBsingh/master
FIX: plot_date ignores timezone Closes #5575 Conflicts: lib/matplotlib/tests/test_axes.py multiple PRs added tests at same location in file keep all.
1 parent 1d7f0d9 commit 44afc73
Copy full SHA for 44afc73

File tree

Expand file treeCollapse file tree

5 files changed

+57
-2
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+57
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,13 +1491,13 @@ def plot_date(self, x, y, fmt='o', tz=None, xdate=True, ydate=False,
14911491
if not self._hold:
14921492
self.cla()
14931493

1494-
ret = self.plot(x, y, fmt, **kwargs)
1495-
14961494
if xdate:
14971495
self.xaxis_date(tz)
14981496
if ydate:
14991497
self.yaxis_date(tz)
15001498

1499+
ret = self.plot(x, y, fmt, **kwargs)
1500+
15011501
self.autoscale_view()
15021502

15031503
return ret
Loading
Loading
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import datetime
1313

14+
import pytz
15+
1416
import numpy as np
1517
from numpy import ma
1618
from numpy import arange
@@ -4213,6 +4215,7 @@ def test_pandas_indexing_hist():
42134215
fig, axes = plt.subplots()
42144216
axes.hist(ser_2)
42154217

4218+
42164219
@cleanup
42174220
def test_axis_set_tick_params_labelsize_labelcolor():
42184221
# Tests fix for issue 4346
@@ -4225,6 +4228,58 @@ def test_axis_set_tick_params_labelsize_labelcolor():
42254228
assert axis_1.yaxis.majorTicks[0]._labelsize == 30.0
42264229
assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red'
42274230

4231+
4232+
@image_comparison(baseline_images=['date_timezone_x'], extensions=['png'])
4233+
def test_date_timezone_x():
4234+
# Tests issue 5575
4235+
time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(
4236+
year=2016, month=2, day=22, hour=x)) for x in range(3)]
4237+
4238+
# Same Timezone
4239+
fig = plt.figure(figsize=(20, 12))
4240+
plt.subplot(2, 1, 1)
4241+
plt.plot_date(time_index, [3] * 3, tz='Canada/Eastern')
4242+
4243+
# Different Timezone
4244+
plt.subplot(2, 1, 2)
4245+
plt.plot_date(time_index, [3] * 3, tz='UTC')
4246+
4247+
4248+
@image_comparison(baseline_images=['date_timezone_y'],
4249+
extensions=['png'])
4250+
def test_date_timezone_y():
4251+
# Tests issue 5575
4252+
time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(
4253+
year=2016, month=2, day=22, hour=x)) for x in range(3)]
4254+
4255+
# Same Timezone
4256+
fig = plt.figure(figsize=(20, 12))
4257+
plt.subplot(2, 1, 1)
4258+
plt.plot_date([3] * 3,
4259+
time_index, tz='Canada/Eastern', xdate=False, ydate=True)
4260+
4261+
# Different Timezone
4262+
plt.subplot(2, 1, 2)
4263+
plt.plot_date([3] * 3, time_index, tz='UTC', xdate=False, ydate=True)
4264+
4265+
4266+
@image_comparison(baseline_images=['date_timezone_x_and_y'],
4267+
extensions=['png'])
4268+
def test_date_timezone_x_and_y():
4269+
# Tests issue 5575
4270+
time_index = [pytz.timezone('UTC').localize(datetime.datetime(
4271+
year=2016, month=2, day=22, hour=x)) for x in range(3)]
4272+
4273+
# Same Timezone
4274+
fig = plt.figure(figsize=(20, 12))
4275+
plt.subplot(2, 1, 1)
4276+
plt.plot_date(time_index, time_index, tz='UTC', ydate=True)
4277+
4278+
# Different Timezone
4279+
plt.subplot(2, 1, 2)
4280+
plt.plot_date(time_index, time_index, tz='US/Eastern', ydate=True)
4281+
4282+
42284283
if __name__ == '__main__':
42294284
import nose
42304285
import sys

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.