From f8d76160cca7f3a05e13ea2072f37c0f43affbd2 Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Thu, 30 Jul 2015 15:30:53 -0400 Subject: [PATCH 1/2] mep12 changes to axes_props.py --- examples/pylab_examples/axes_props.py | 41 ++++----------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/examples/pylab_examples/axes_props.py b/examples/pylab_examples/axes_props.py index 2697fca37c52..6a1daeceb774 100644 --- a/examples/pylab_examples/axes_props.py +++ b/examples/pylab_examples/axes_props.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ You can control the axis tick and grid properties """ @@ -7,45 +6,17 @@ import numpy as np t = np.arange(0.0, 2.0, 0.01) -s = np.sin(2*np.pi*t) -plt.plot(t, s) -plt.grid(True) - -# MATLAB style -xticklines = plt.getp(plt.gca(), 'xticklines') -yticklines = plt.getp(plt.gca(), 'yticklines') -xgridlines = plt.getp(plt.gca(), 'xgridlines') -ygridlines = plt.getp(plt.gca(), 'ygridlines') -xticklabels = plt.getp(plt.gca(), 'xticklabels') -yticklabels = plt.getp(plt.gca(), 'yticklabels') - -plt.setp(xticklines, 'linewidth', 3) -plt.setp(yticklines, 'linewidth', 3) -plt.setp(xgridlines, 'linestyle', '-') -plt.setp(ygridlines, 'linestyle', '-') -plt.setp(yticklabels, 'color', 'r', fontsize='medium') -plt.setp(xticklabels, 'color', 'r', fontsize='medium') - - -plt.show() - - -""" -# the same script, python style -from pylab import * - -t = arange(0.0, 2.0, 0.01) -s = sin(2*pi*t) +s = np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s) ax.grid(True) ticklines = ax.get_xticklines() -ticklines.extend( ax.get_yticklines() ) +ticklines.extend(ax.get_yticklines()) gridlines = ax.get_xgridlines() -gridlines.extend( ax.get_ygridlines() ) +gridlines.extend(ax.get_ygridlines()) ticklabels = ax.get_xticklabels() -ticklabels.extend( ax.get_yticklabels() ) +ticklabels.extend(ax.get_yticklabels()) for line in ticklines: line.set_linewidth(3) @@ -57,6 +28,4 @@ label.set_color('r') label.set_fontsize('medium') -show() - -""" +plt.show() From 3907ecd8d00135e2b15f93f2b3fb9e34596d9027 Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Thu, 30 Jul 2015 16:21:38 -0400 Subject: [PATCH 2/2] made gridlines, ticklines and ticklabels code cleaner --- examples/pylab_examples/axes_props.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/pylab_examples/axes_props.py b/examples/pylab_examples/axes_props.py index 6a1daeceb774..dff7c762d295 100644 --- a/examples/pylab_examples/axes_props.py +++ b/examples/pylab_examples/axes_props.py @@ -11,12 +11,9 @@ ax.plot(t, s) ax.grid(True) -ticklines = ax.get_xticklines() -ticklines.extend(ax.get_yticklines()) -gridlines = ax.get_xgridlines() -gridlines.extend(ax.get_ygridlines()) -ticklabels = ax.get_xticklabels() -ticklabels.extend(ax.get_yticklabels()) +ticklines = ax.get_xticklines() + ax.get_yticklines() +gridlines = ax.get_xgridlines() + ax.get_ygridlines() +ticklabels = ax.get_xticklabels() + ax.get_yticklabels() for line in ticklines: line.set_linewidth(3)