Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix for issue 5575 along with testing #6091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,13 +1492,13 @@ def plot_date(self, x, y, fmt='o', tz=None, xdate=True, ydate=False,
if not self._hold:
self.cla()

ret = self.plot(x, y, fmt, **kwargs)

if xdate:
self.xaxis_date(tz)
if ydate:
self.yaxis_date(tz)

ret = self.plot(x, y, fmt, **kwargs)

self.autoscale_view()

return ret
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import datetime

import pytz

import numpy as np
from numpy import ma
from numpy import arange
Expand Down Expand Up @@ -4335,6 +4337,55 @@ def test_pandas_indexing_hist():
fig, axes = plt.subplots()
axes.hist(ser_2)

@image_comparison(baseline_images=['date_timezone_x'], extensions=['png'])
def test_date_timezone_x():
# Tests issue 5575
time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(
year=2016, month=2, day=22, hour=x)) for x in range(3)]

# Same Timezone
fig = plt.figure(figsize=(20, 12))
plt.subplot(2, 1, 1)
plt.plot_date(time_index, [3] * 3, tz='Canada/Eastern')

# Different Timezone
plt.subplot(2, 1, 2)
plt.plot_date(time_index, [3] * 3, tz='UTC')


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use two empty lines between functions (this file is not yet checked against PEP8.) You only need to add them around the functions you've added.

@image_comparison(baseline_images=['date_timezone_y'],
extensions=['png'])
def test_date_timezone_y():
# Tests issue 5575
time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(
year=2016, month=2, day=22, hour=x)) for x in range(3)]

# Same Timezone
fig = plt.figure(figsize=(20, 12))
plt.subplot(2, 1, 1)
plt.plot_date([3] * 3,
time_index, tz='Canada/Eastern', xdate=False, ydate=True)

# Different Timezone
plt.subplot(2, 1, 2)
plt.plot_date([3] * 3, time_index, tz='UTC', xdate=False, ydate=True)


@image_comparison(baseline_images=['date_timezone_x_and_y'],
extensions=['png'])
def test_date_timezone_x_and_y():
# Tests issue 5575
time_index = [pytz.timezone('UTC').localize(datetime.datetime(
year=2016, month=2, day=22, hour=x)) for x in range(3)]

# Same Timezone
fig = plt.figure(figsize=(20, 12))
plt.subplot(2, 1, 1)
plt.plot_date(time_index, time_index, tz='UTC', ydate=True)

# Different Timezone
plt.subplot(2, 1, 2)
plt.plot_date(time_index, time_index, tz='US/Eastern', ydate=True)

if __name__ == '__main__':
import nose
Expand Down