From 6fe05fb997244953cd0b29466242974a63f90932 Mon Sep 17 00:00:00 2001 From: ZWL Date: Sun, 21 Jan 2018 22:35:00 +0000 Subject: [PATCH 01/11] Add ytick label right/left properties in matplotlibrc. issue #10267 --- lib/matplotlib/axes/_base.py | 8 ++++++++ lib/matplotlib/rcsetup.py | 2 ++ matplotlibrc.template | 2 ++ 3 files changed, 12 insertions(+) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 614c943d73d1..2a2f1e38da0f 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -559,6 +559,10 @@ def __init__(self, fig, rect, bottom=rcParams['xtick.bottom'] and rcParams['xtick.minor.bottom'], left=rcParams['ytick.left'] and rcParams['ytick.minor.left'], right=rcParams['ytick.right'] and rcParams['ytick.minor.right'], + labelleft=rcParams['ytick.labelleft'] and + rcParams['ytick.minor.left'], + labelright=rcParams['ytick.labelright'] and + rcParams['ytick.minor.right'], which='minor') self.tick_params( @@ -566,6 +570,10 @@ def __init__(self, fig, rect, bottom=rcParams['xtick.bottom'] and rcParams['xtick.major.bottom'], left=rcParams['ytick.left'] and rcParams['ytick.major.left'], right=rcParams['ytick.right'] and rcParams['ytick.major.right'], + labelleft=rcParams['ytick.labelleft'] and + rcParams['ytick.major.left'], + labelright=rcParams['ytick.labelright'] and + rcParams['ytick.major.right'], which='major') def __getstate__(self): diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index eafc8d4eecf7..29c177f54c03 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1234,6 +1234,8 @@ def _validate_linestyle(ls): 'ytick.left': [True, validate_bool], # draw ticks on the left side 'ytick.right': [False, validate_bool], # draw ticks on the right side + 'ytick.labelleft': [True, validate_bool], # draw tick labels on the left side + 'ytick.labelright': [False, validate_bool], # draw tick labels on the right side 'ytick.major.size': [3.5, validate_float], # major ytick size in points 'ytick.minor.size': [2, validate_float], # minor ytick size in points 'ytick.major.width': [0.8, validate_float], # major ytick width in points diff --git a/matplotlibrc.template b/matplotlibrc.template index 7ac32f71cf8d..a9234d15e610 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -379,6 +379,8 @@ backend : $TEMPLATE_BACKEND #ytick.left : True # draw ticks on the left side #ytick.right : False # draw ticks on the right side +#ytick.labelleft : True # draw tick labels on the left side +#ytick.labelright : False # draw tick labels on the right side #ytick.major.size : 3.5 # major tick size in points #ytick.minor.size : 2 # minor tick size in points #ytick.major.width : 0.8 # major tick width in points From 3a7cebf4167e27630ac277e5c38dabd07081cd1d Mon Sep 17 00:00:00 2001 From: ZWL Date: Sun, 28 Jan 2018 20:30:59 +0000 Subject: [PATCH 02/11] reformat code --- lib/matplotlib/axes/_base.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 2a2f1e38da0f..9cb739a7424c 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -559,10 +559,10 @@ def __init__(self, fig, rect, bottom=rcParams['xtick.bottom'] and rcParams['xtick.minor.bottom'], left=rcParams['ytick.left'] and rcParams['ytick.minor.left'], right=rcParams['ytick.right'] and rcParams['ytick.minor.right'], - labelleft=rcParams['ytick.labelleft'] and - rcParams['ytick.minor.left'], - labelright=rcParams['ytick.labelright'] and - rcParams['ytick.minor.right'], + labelleft=(rcParams['ytick.labelleft'] and + rcParams['ytick.minor.left']), + labelright=(rcParams['ytick.labelright'] and + rcParams['ytick.minor.right']), which='minor') self.tick_params( @@ -570,10 +570,10 @@ def __init__(self, fig, rect, bottom=rcParams['xtick.bottom'] and rcParams['xtick.major.bottom'], left=rcParams['ytick.left'] and rcParams['ytick.major.left'], right=rcParams['ytick.right'] and rcParams['ytick.major.right'], - labelleft=rcParams['ytick.labelleft'] and - rcParams['ytick.major.left'], - labelright=rcParams['ytick.labelright'] and - rcParams['ytick.major.right'], + labelleft=(rcParams['ytick.labelleft'] and + rcParams['ytick.major.left']), + labelright=(rcParams['ytick.labelright'] and + rcParams['ytick.major.right']), which='major') def __getstate__(self): From f30e583cd044b5d987048711211931777f8440e6 Mon Sep 17 00:00:00 2001 From: ZWL Date: Sun, 28 Jan 2018 21:18:24 +0000 Subject: [PATCH 03/11] added test for issue #10267, yaxis tick label left/right --- lib/matplotlib/tests/test_axes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 3e86a6296fa5..506ecf6d8b9c 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5224,6 +5224,20 @@ def test_axes_tick_params_gridlines(): assert axis.majorTicks[0]._grid_linestyle == 'dashdot' +def test_axes_tick_params_ylabelside(): + # Tests fix for issue 10267 + ax = plt.subplot() + ax.tick_params(labelleft=False, labelright=True, + which='major') + ax.tick_params(labelleft=False, labelright=True, + which='minor') + # expects left false, right true + assert(ax.yaxis.majorTicks[0].label1On is False) + assert(ax.yaxis.majorTicks[0].label2On is True) + assert(ax.yaxis.minorTicks[0].label1On is False) + assert(ax.yaxis.minorTicks[0].label2On is True) + + def test_none_kwargs(): fig, ax = plt.subplots() ln, = ax.plot(range(32), linestyle=None) From c09536ba793a35a07cf4de477afb874a4a1fc93d Mon Sep 17 00:00:00 2001 From: ZWL Date: Tue, 30 Jan 2018 21:42:46 +0000 Subject: [PATCH 04/11] Added example and whatsnew for issue 10267 yaxis tick label side. --- .../2018_01_30_tick_label_right.rst | 9 +++++ examples/ticks_and_spines/tick_label_right.py | 35 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 doc/users/next_whats_new/2018_01_30_tick_label_right.rst create mode 100644 examples/ticks_and_spines/tick_label_right.py diff --git a/doc/users/next_whats_new/2018_01_30_tick_label_right.rst b/doc/users/next_whats_new/2018_01_30_tick_label_right.rst new file mode 100644 index 000000000000..b23b67a1837d --- /dev/null +++ b/doc/users/next_whats_new/2018_01_30_tick_label_right.rst @@ -0,0 +1,9 @@ +Properties in `.matplotlibrc` to place yaxis tick labels on LEFT or RIGHT +------------------------------------------------------------------------------- + +Introducing two new boolean properties in `.matplotlibrc` to place yaxis tick +labels on the left or right hand side of a figure by default, namely, +`ytick.labelright` and `ytick.labelleft`. These can also be changed in +rcParams. + + diff --git a/examples/ticks_and_spines/tick_label_right.py b/examples/ticks_and_spines/tick_label_right.py new file mode 100644 index 000000000000..faea2b465b72 --- /dev/null +++ b/examples/ticks_and_spines/tick_label_right.py @@ -0,0 +1,35 @@ +""" +============================================ +Set default y-axis tick labels on the right +============================================ + +Example to show how to change two new properties in rcParams to put yaxis tick +lables on either left or right by default. + +These properties can also be set in .matplotlibrc: + +ytick.labelright +ytick.labelleft +""" + + +import matplotlib.pyplot as plt +import numpy as np + + +x = np.array([x for x in range(10)]) + +_, ax = plt.subplots(3, 1, sharex=True, figsize=(6, 6)) + +ax[0].plot(x) +ax[0].yaxis.tick_right() + +ax[1].plot(x) +ax[1].yaxis.tick_left() + +plt.rcParams['ytick.right'], plt.rcParams['ytick.labelright'] = True, True +plt.rcParams['ytick.left'], plt.rcParams['ytick.labelleft'] = False, False + +ax[2].plot(x) + +plt.show() From b5d3a11f288d80b3584a6f2629f4ae2e4f3782a3 Mon Sep 17 00:00:00 2001 From: ZWL Date: Tue, 30 Jan 2018 22:58:50 +0000 Subject: [PATCH 05/11] fix tick label right example --- examples/ticks_and_spines/tick_label_right.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/ticks_and_spines/tick_label_right.py b/examples/ticks_and_spines/tick_label_right.py index faea2b465b72..632139e71d01 100644 --- a/examples/ticks_and_spines/tick_label_right.py +++ b/examples/ticks_and_spines/tick_label_right.py @@ -16,20 +16,18 @@ import matplotlib.pyplot as plt import numpy as np +plt.rcParams['ytick.right'], plt.rcParams['ytick.labelright'] = True, True +plt.rcParams['ytick.left'], plt.rcParams['ytick.labelleft'] = False, False + x = np.array([x for x in range(10)]) -_, ax = plt.subplots(3, 1, sharex=True, figsize=(6, 6)) +_, ax = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) ax[0].plot(x) -ax[0].yaxis.tick_right() +ax[0].yaxis.tick_left() +# use default parameter in rcParams, not calling tick_right() ax[1].plot(x) -ax[1].yaxis.tick_left() - -plt.rcParams['ytick.right'], plt.rcParams['ytick.labelright'] = True, True -plt.rcParams['ytick.left'], plt.rcParams['ytick.labelleft'] = False, False - -ax[2].plot(x) plt.show() From 600d76166bbb560589e3db2ce080be2e62f65e56 Mon Sep 17 00:00:00 2001 From: ZWL Date: Wed, 31 Jan 2018 21:23:02 +0000 Subject: [PATCH 06/11] tick_label_right example comment changes. --- examples/ticks_and_spines/tick_label_right.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/ticks_and_spines/tick_label_right.py b/examples/ticks_and_spines/tick_label_right.py index 632139e71d01..d951a9e0e507 100644 --- a/examples/ticks_and_spines/tick_label_right.py +++ b/examples/ticks_and_spines/tick_label_right.py @@ -3,13 +3,11 @@ Set default y-axis tick labels on the right ============================================ -Example to show how to change two new properties in rcParams to put yaxis tick -lables on either left or right by default. +We can use :rc:`ytick.labelright` (default False) and :rc:`ytick.right` +(default False) and :rc:`ytick.labelleft` (default True) and :rc:`ytick.left` +(default True) to control where on the axes ticks and their labels appear. +These properties can also be set in the ``.matplotlib/matplotlibrc``. -These properties can also be set in .matplotlibrc: - -ytick.labelright -ytick.labelleft """ From 82ef9cf6f97aae95122ca7340ac6028ecd5728ce Mon Sep 17 00:00:00 2001 From: ZWL Date: Sat, 3 Feb 2018 21:23:38 +0000 Subject: [PATCH 07/11] Added xtick.labeltop and xtick.labelbottom for matplotlibrc --- examples/ticks_and_spines/tick_xlabel_top.py | 26 ++++++++++++++++++++ lib/matplotlib/axes/_base.py | 8 ++++++ lib/matplotlib/rcsetup.py | 2 ++ lib/matplotlib/tests/test_axes.py | 16 ++++++++++++ matplotlibrc.template | 2 ++ 5 files changed, 54 insertions(+) create mode 100644 examples/ticks_and_spines/tick_xlabel_top.py diff --git a/examples/ticks_and_spines/tick_xlabel_top.py b/examples/ticks_and_spines/tick_xlabel_top.py new file mode 100644 index 000000000000..ff80e350eb96 --- /dev/null +++ b/examples/ticks_and_spines/tick_xlabel_top.py @@ -0,0 +1,26 @@ +""" +========================================== +Set default x-axis tick labels on the top +========================================== + +We can use :rc:`xtick.labeltop` (default False) and :rc:`xtick.top` +(default False) and :rc:`xtick.labelbottom` (default True) and +:rc:`xtick.bottom` (default True) to control where on the axes ticks and +their labels appear. +These properties can also be set in the ``.matplotlib/matplotlibrc``. + +""" + + +import matplotlib.pyplot as plt +import numpy as np + + +plt.rcParams['xtick.bottom'], plt.rcParams['xtick.labelbottom'] = False, False +plt.rcParams['xtick.top'], plt.rcParams['xtick.labeltop'] = True, True + +x = np.array([x for x in range(10)]) + +plt.plot(x) +plt.title('xlabel top') +plt.show() diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 865fc3a6bf66..d899ef5757e3 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -549,6 +549,10 @@ def __init__(self, fig, rect, self.tick_params( top=rcParams['xtick.top'] and rcParams['xtick.minor.top'], bottom=rcParams['xtick.bottom'] and rcParams['xtick.minor.bottom'], + labeltop=(rcParams['xtick.labeltop'] and + rcParams['xtick.minor.top']), + labelbottom=(rcParams['xtick.labelbottom'] and + rcParams['xtick.minor.bottom']), left=rcParams['ytick.left'] and rcParams['ytick.minor.left'], right=rcParams['ytick.right'] and rcParams['ytick.minor.right'], labelleft=(rcParams['ytick.labelleft'] and @@ -560,6 +564,10 @@ def __init__(self, fig, rect, self.tick_params( top=rcParams['xtick.top'] and rcParams['xtick.major.top'], bottom=rcParams['xtick.bottom'] and rcParams['xtick.major.bottom'], + labeltop=(rcParams['xtick.labeltop'] and + rcParams['xtick.major.top']), + labelbottom=(rcParams['xtick.labelbottom'] and + rcParams['xtick.major.bottom']), left=rcParams['ytick.left'] and rcParams['ytick.major.left'], right=rcParams['ytick.right'] and rcParams['ytick.major.right'], labelleft=(rcParams['ytick.labelleft'] and diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 3d1eb748ca0d..6bbd9ead2de4 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1234,6 +1234,8 @@ def _validate_linestyle(ls): # tick properties 'xtick.top': [False, validate_bool], # draw ticks on the top side 'xtick.bottom': [True, validate_bool], # draw ticks on the bottom side + 'xtick.labeltop': [False, validate_bool], # draw label on the top + 'xtick.labelbottom': [True, validate_bool], # draw label on the bottom 'xtick.major.size': [3.5, validate_float], # major xtick size in points 'xtick.minor.size': [2, validate_float], # minor xtick size in points 'xtick.major.width': [0.8, validate_float], # major xtick width in points diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 506ecf6d8b9c..f0bf8776ed48 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5238,6 +5238,22 @@ def test_axes_tick_params_ylabelside(): assert(ax.yaxis.minorTicks[0].label2On is True) +def test_axes_tick_params_xlabelside(): + # Tests fix for issue 10267 + ax = plt.subplot() + ax.tick_params(labeltop=True, labelbottom=False, + which='major') + ax.tick_params(labeltop=True, labelbottom=False, + which='minor') + # expects top True, bottom False + # label1On mapped to labelbottom + # label2On mapped to labeltop + assert(ax.xaxis.majorTicks[0].label1On is False) + assert(ax.xaxis.majorTicks[0].label2On is True) + assert(ax.xaxis.minorTicks[0].label1On is False) + assert(ax.xaxis.minorTicks[0].label2On is True) + + def test_none_kwargs(): fig, ax = plt.subplots() ln, = ax.plot(range(32), linestyle=None) diff --git a/matplotlibrc.template b/matplotlibrc.template index c426f341086d..feee0a72aa1d 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -357,6 +357,8 @@ backend : $TEMPLATE_BACKEND # see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick #xtick.top : False # draw ticks on the top side #xtick.bottom : True # draw ticks on the bottom side +#xtick.labeltop : False # draw label on the top +#xtick.labelbottom : True # draw label on the bottom #xtick.major.size : 3.5 # major tick size in points #xtick.minor.size : 2 # minor tick size in points #xtick.major.width : 0.8 # major tick width in points From d805368428226c9435559eacf8f2f25d4bb0d80a Mon Sep 17 00:00:00 2001 From: ZWL Date: Sat, 3 Feb 2018 21:29:38 +0000 Subject: [PATCH 08/11] Added xtick.labeltop/labelbottom in whatsnew --- .../next_whats_new/2018_01_30_tick_label_positions.rst | 9 +++++++++ doc/users/next_whats_new/2018_01_30_tick_label_right.rst | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 doc/users/next_whats_new/2018_01_30_tick_label_positions.rst delete mode 100644 doc/users/next_whats_new/2018_01_30_tick_label_right.rst diff --git a/doc/users/next_whats_new/2018_01_30_tick_label_positions.rst b/doc/users/next_whats_new/2018_01_30_tick_label_positions.rst new file mode 100644 index 000000000000..ce402c3aafb2 --- /dev/null +++ b/doc/users/next_whats_new/2018_01_30_tick_label_positions.rst @@ -0,0 +1,9 @@ +Properties in `matplotlibrc` to place xasis and yaxis tick labels +------------------------------------------------------------------------------- + +Introducing four new boolean properties in `.matplotlibrc` for default +positions of xaxis and yaxis tick labels, namely, +`xtick.labeltop`, `xtick.labelbottom`, `ytick.labelright` and +`ytick.labelleft`. These can also be changed in rcParams. + + diff --git a/doc/users/next_whats_new/2018_01_30_tick_label_right.rst b/doc/users/next_whats_new/2018_01_30_tick_label_right.rst deleted file mode 100644 index b23b67a1837d..000000000000 --- a/doc/users/next_whats_new/2018_01_30_tick_label_right.rst +++ /dev/null @@ -1,9 +0,0 @@ -Properties in `.matplotlibrc` to place yaxis tick labels on LEFT or RIGHT -------------------------------------------------------------------------------- - -Introducing two new boolean properties in `.matplotlibrc` to place yaxis tick -labels on the left or right hand side of a figure by default, namely, -`ytick.labelright` and `ytick.labelleft`. These can also be changed in -rcParams. - - From d7fcb5eba1049bacfca3f2dd1b0d373fdd8ff554 Mon Sep 17 00:00:00 2001 From: ZWL Date: Sun, 4 Feb 2018 21:02:03 +0000 Subject: [PATCH 09/11] test and example minor code changes. --- examples/ticks_and_spines/tick_label_right.py | 6 +++--- examples/ticks_and_spines/tick_xlabel_top.py | 6 +++--- lib/matplotlib/tests/test_axes.py | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/ticks_and_spines/tick_label_right.py b/examples/ticks_and_spines/tick_label_right.py index d951a9e0e507..7281d0cbc8c8 100644 --- a/examples/ticks_and_spines/tick_label_right.py +++ b/examples/ticks_and_spines/tick_label_right.py @@ -14,11 +14,11 @@ import matplotlib.pyplot as plt import numpy as np -plt.rcParams['ytick.right'], plt.rcParams['ytick.labelright'] = True, True -plt.rcParams['ytick.left'], plt.rcParams['ytick.labelleft'] = False, False +plt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True +plt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False -x = np.array([x for x in range(10)]) +x = np.array([x for x in np.range(10)]) _, ax = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) diff --git a/examples/ticks_and_spines/tick_xlabel_top.py b/examples/ticks_and_spines/tick_xlabel_top.py index ff80e350eb96..8d3f6eee52e9 100644 --- a/examples/ticks_and_spines/tick_xlabel_top.py +++ b/examples/ticks_and_spines/tick_xlabel_top.py @@ -16,10 +16,10 @@ import numpy as np -plt.rcParams['xtick.bottom'], plt.rcParams['xtick.labelbottom'] = False, False -plt.rcParams['xtick.top'], plt.rcParams['xtick.labeltop'] = True, True +plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False +plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True -x = np.array([x for x in range(10)]) +x = np.array([x for x in np.range(10)]) plt.plot(x) plt.title('xlabel top') diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index f0bf8776ed48..04ef89f736e3 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5232,10 +5232,10 @@ def test_axes_tick_params_ylabelside(): ax.tick_params(labelleft=False, labelright=True, which='minor') # expects left false, right true - assert(ax.yaxis.majorTicks[0].label1On is False) - assert(ax.yaxis.majorTicks[0].label2On is True) - assert(ax.yaxis.minorTicks[0].label1On is False) - assert(ax.yaxis.minorTicks[0].label2On is True) + assert ax.yaxis.majorTicks[0].label1On is False + assert ax.yaxis.majorTicks[0].label2On is True + assert ax.yaxis.minorTicks[0].label1On is False + assert ax.yaxis.minorTicks[0].label2On is True def test_axes_tick_params_xlabelside(): @@ -5248,10 +5248,10 @@ def test_axes_tick_params_xlabelside(): # expects top True, bottom False # label1On mapped to labelbottom # label2On mapped to labeltop - assert(ax.xaxis.majorTicks[0].label1On is False) - assert(ax.xaxis.majorTicks[0].label2On is True) - assert(ax.xaxis.minorTicks[0].label1On is False) - assert(ax.xaxis.minorTicks[0].label2On is True) + assert ax.xaxis.majorTicks[0].label1On is False + assert ax.xaxis.majorTicks[0].label2On is True + assert ax.xaxis.minorTicks[0].label1On is False + assert ax.xaxis.minorTicks[0].label2On is True def test_none_kwargs(): From d1efa254f1ffa6bb5157047d933e3651f7eaab8b Mon Sep 17 00:00:00 2001 From: ZWL Date: Sun, 4 Feb 2018 21:04:52 +0000 Subject: [PATCH 10/11] example minor code change. --- examples/ticks_and_spines/tick_label_right.py | 2 +- examples/ticks_and_spines/tick_xlabel_top.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ticks_and_spines/tick_label_right.py b/examples/ticks_and_spines/tick_label_right.py index 7281d0cbc8c8..9d5036eea25b 100644 --- a/examples/ticks_and_spines/tick_label_right.py +++ b/examples/ticks_and_spines/tick_label_right.py @@ -18,7 +18,7 @@ plt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False -x = np.array([x for x in np.range(10)]) +x = np.array([x for x in np.arange(10)]) _, ax = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) diff --git a/examples/ticks_and_spines/tick_xlabel_top.py b/examples/ticks_and_spines/tick_xlabel_top.py index 8d3f6eee52e9..bb607e23e647 100644 --- a/examples/ticks_and_spines/tick_xlabel_top.py +++ b/examples/ticks_and_spines/tick_xlabel_top.py @@ -19,7 +19,7 @@ plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True -x = np.array([x for x in np.range(10)]) +x = np.array([x for x in np.arange(10)]) plt.plot(x) plt.title('xlabel top') From 145b409584359f18ea649ff4432dfdc23f85e03d Mon Sep 17 00:00:00 2001 From: ZWL Date: Sun, 4 Feb 2018 21:08:53 +0000 Subject: [PATCH 11/11] replace with np.arange() --- examples/ticks_and_spines/tick_label_right.py | 2 +- examples/ticks_and_spines/tick_xlabel_top.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ticks_and_spines/tick_label_right.py b/examples/ticks_and_spines/tick_label_right.py index 9d5036eea25b..8b4a8a9613f1 100644 --- a/examples/ticks_and_spines/tick_label_right.py +++ b/examples/ticks_and_spines/tick_label_right.py @@ -18,7 +18,7 @@ plt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False -x = np.array([x for x in np.arange(10)]) +x = np.arange(10) _, ax = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) diff --git a/examples/ticks_and_spines/tick_xlabel_top.py b/examples/ticks_and_spines/tick_xlabel_top.py index bb607e23e647..d13ddea27a03 100644 --- a/examples/ticks_and_spines/tick_xlabel_top.py +++ b/examples/ticks_and_spines/tick_xlabel_top.py @@ -19,7 +19,7 @@ plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True -x = np.array([x for x in np.arange(10)]) +x = np.arange(10) plt.plot(x) plt.title('xlabel top')