From f758834918eeb886f1f79540e375d1fff153a6f5 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 4 Feb 2017 14:16:45 -0800 Subject: [PATCH 1/7] Allow choosing logit scale in qt figure options. --- lib/matplotlib/backends/qt_editor/figureoptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/qt_editor/figureoptions.py b/lib/matplotlib/backends/qt_editor/figureoptions.py index 824db2c7bd76..d7062d694317 100644 --- a/lib/matplotlib/backends/qt_editor/figureoptions.py +++ b/lib/matplotlib/backends/qt_editor/figureoptions.py @@ -54,12 +54,12 @@ def figure_edit(axes, parent=None): (None, "X-Axis"), ('Min', xmin), ('Max', xmax), ('Label', axes.get_xlabel()), - ('Scale', [axes.get_xscale(), 'linear', 'log']), + ('Scale', [axes.get_xscale(), 'linear', 'log', 'logit']), sep, (None, "Y-Axis"), ('Min', ymin), ('Max', ymax), ('Label', axes.get_ylabel()), - ('Scale', [axes.get_yscale(), 'linear', 'log']), + ('Scale', [axes.get_yscale(), 'linear', 'log', 'logit']), sep, ('(Re-)Generate automatic legend', False), ] From 7eceed5538d1f1232708d82a6c599cf9a0d079cf Mon Sep 17 00:00:00 2001 From: Yasaman-Mah Date: Sat, 4 Mar 2017 11:02:54 -0500 Subject: [PATCH 2/7] fix #7742 --- lib/matplotlib/axes/_axes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 5ffd8a7bae08..da8cca55ce3d 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -725,6 +725,7 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs): trans = self.get_yaxis_transform(which='grid') l = mlines.Line2D([xmin, xmax], [y, y], transform=trans, **kwargs) self.add_line(l) + self.ignore_existing_data_limits = True self.autoscale_view(scalex=False, scaley=scaley) return l From 52beee2131efb33bebe28469fac7e9a6ac9d869b Mon Sep 17 00:00:00 2001 From: Yasaman-Mah Date: Sat, 4 Mar 2017 12:25:17 -0500 Subject: [PATCH 3/7] test case for bug fix 7742 --- lib/matplotlib/tests/test_axes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 41d604808b5d..33a79547d27c 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4972,3 +4972,21 @@ def test_bar_single_height(): ax.bar(range(4), 1) # Check that a horizontal chart with one width works ax.bar(0, 1, bottom=range(4), width=1, orientation='horizontal') + +def test_datetime_axhline_same_axes(): + # This test was suggested by Paul Hobson (@phobson) regarding issue 7742 + # Check when ploting datetime data and horizontal line + # order of plotting doesn't matter. + # axhline() should not change x axis limits. + from datetime import datetime + fig, axs = plt.subplots(2, 1) + xvalues = [datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)] + yvalues = [1, 2] + + axs[0].plot(xvalues, yvalues) + axs[0].axhline(1.5) + + axs[1].axhline(1.5) + axs[1].plot(xvalues, yvalues) + + assert (axs[0].get_xlim() == axs[1].get_xlim()) From a3dbc3cdbd4eea1897157902f26b911e91360825 Mon Sep 17 00:00:00 2001 From: Yasaman-Mah Date: Sat, 4 Mar 2017 12:33:07 -0500 Subject: [PATCH 4/7] fixed indentation --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index da8cca55ce3d..60e7fee909d4 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -725,7 +725,7 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs): trans = self.get_yaxis_transform(which='grid') l = mlines.Line2D([xmin, xmax], [y, y], transform=trans, **kwargs) self.add_line(l) - self.ignore_existing_data_limits = True + self.ignore_existing_data_limits = True self.autoscale_view(scalex=False, scaley=scaley) return l From b37ffc579ff9800968757fe6b75e2df858c9c593 Mon Sep 17 00:00:00 2001 From: Isa Hassen Date: Tue, 7 Mar 2017 07:38:48 -0500 Subject: [PATCH 5/7] fix pep8 --- lib/matplotlib/tests/test_axes.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 33a79547d27c..fed29a844fea 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4973,20 +4973,21 @@ def test_bar_single_height(): # Check that a horizontal chart with one width works ax.bar(0, 1, bottom=range(4), width=1, orientation='horizontal') + def test_datetime_axhline_same_axes(): # This test was suggested by Paul Hobson (@phobson) regarding issue 7742 - # Check when ploting datetime data and horizontal line + # Check when ploting datetime data and horizontal line # order of plotting doesn't matter. # axhline() should not change x axis limits. from datetime import datetime fig, axs = plt.subplots(2, 1) xvalues = [datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)] yvalues = [1, 2] - + axs[0].plot(xvalues, yvalues) axs[0].axhline(1.5) - + axs[1].axhline(1.5) axs[1].plot(xvalues, yvalues) - + assert (axs[0].get_xlim() == axs[1].get_xlim()) From 4fa59c6609a17fdf4a1cec8058b2759811b0aa49 Mon Sep 17 00:00:00 2001 From: Yasaman-Mah Date: Wed, 15 Mar 2017 22:33:23 -0400 Subject: [PATCH 6/7] added similar changes to axvline. --- lib/matplotlib/axes/_axes.py | 1 + lib/matplotlib/tests/test_axes.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 60e7fee909d4..b7b5916666c8 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -792,6 +792,7 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs): trans = self.get_xaxis_transform(which='grid') l = mlines.Line2D([x, x], [ymin, ymax], transform=trans, **kwargs) self.add_line(l) + self.ignore_existing_data_limits = True self.autoscale_view(scalex=scalex, scaley=False) return l diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 33a79547d27c..210fe5fb2498 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4990,3 +4990,18 @@ def test_datetime_axhline_same_axes(): axs[1].plot(xvalues, yvalues) assert (axs[0].get_xlim() == axs[1].get_xlim()) + +def test_datetime_axvline_same_axes(): + # This is similar to test above + from datetime import datetime + fig, axs = plt.subplots(2,1) + xvalues = [1, 2] + yvalues = [datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)] + + axs[0].plot(xvalues, yvalues) + axs[0].axvline(1.5) + + axs[1].axvline(1.5) + axs[1].plot(xvalues, yvalues) + + assert (axs[0].get_ylim() == axs[1].get_ylim()) From 8c9ef18a0b1f98f73c5da3750d79220ede2cfbe2 Mon Sep 17 00:00:00 2001 From: Yasaman-Mah Date: Thu, 16 Mar 2017 10:39:19 -0400 Subject: [PATCH 7/7] fixed pep8 errors. --- lib/matplotlib/tests/test_axes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 2e929328eeef..0115cfcd151e 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4996,16 +4996,16 @@ def test_datetime_axhline_same_axes(): def test_datetime_axvline_same_axes(): # This is similar to test above from datetime import datetime - fig, axs = plt.subplots(2,1) + fig, axs = plt.subplots(2, 1) xvalues = [1, 2] yvalues = [datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)] axs[0].plot(xvalues, yvalues) axs[0].axvline(1.5) - + axs[1].axvline(1.5) axs[1].plot(xvalues, yvalues) - + assert (axs[0].get_ylim() == axs[1].get_ylim())