From a4f474703a5360025567cd2241946410185d2179 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 3 Dec 2016 20:39:57 -0500 Subject: [PATCH 01/11] Remove movie_demo.py. It just shells out to mencoder, which is less available, and we've got better demos that automatically call ffmpeg or whatever with the right arguments. --- examples/pylab_examples/movie_demo.py | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100755 examples/pylab_examples/movie_demo.py diff --git a/examples/pylab_examples/movie_demo.py b/examples/pylab_examples/movie_demo.py deleted file mode 100755 index 4d67d515f4ee..000000000000 --- a/examples/pylab_examples/movie_demo.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- noplot -*- - -from __future__ import print_function - -import os -import matplotlib.pyplot as plt -import numpy as np - -files = [] - -fig, ax = plt.subplots(figsize=(5, 5)) -for i in range(50): # 50 frames - plt.cla() - plt.imshow(np.random.rand(5, 5), interpolation='nearest') - fname = '_tmp%03d.png' % i - print('Saving frame', fname) - plt.savefig(fname) - files.append(fname) - -print('Making movie animation.mpg - this may take a while') -os.system("mencoder 'mf://_tmp*.png' -mf type=png:fps=10 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o animation.mpg") -#os.system("convert _tmp*.png animation.mng") - -# cleanup -for fname in files: - os.remove(fname) From 9c8b7e68eafed1f9b17f9beaf3ba93bfff340bdc Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 3 Dec 2016 20:53:41 -0500 Subject: [PATCH 02/11] Add plt.show to some examples. --- examples/pylab_examples/barchart_demo2.py | 1 + examples/pyplots/dollar_ticks.py | 2 +- examples/pyplots/fig_axes_customize_simple.py | 3 +-- examples/pyplots/fig_axes_labels_simple.py | 2 +- examples/pyplots/fig_x.py | 4 +++- examples/pyplots/whats_new_99_spines.py | 3 +-- lib/matplotlib/tests/test_coding_standards.py | 3 --- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/pylab_examples/barchart_demo2.py b/examples/pylab_examples/barchart_demo2.py index faa2bb76511c..15a6aad415d2 100644 --- a/examples/pylab_examples/barchart_demo2.py +++ b/examples/pylab_examples/barchart_demo2.py @@ -160,3 +160,4 @@ def plot_student_results(student, scores, cohort_size): cohort_size = 62 # The number of other 2nd grade boys arts = plot_student_results(student, scores, cohort_size) +plt.show() diff --git a/examples/pyplots/dollar_ticks.py b/examples/pyplots/dollar_ticks.py index 9c22eb4e1864..ca1069dabb7e 100644 --- a/examples/pyplots/dollar_ticks.py +++ b/examples/pyplots/dollar_ticks.py @@ -17,4 +17,4 @@ tick.label2On = True tick.label2.set_color('green') - +plt.show() diff --git a/examples/pyplots/fig_axes_customize_simple.py b/examples/pyplots/fig_axes_customize_simple.py index 797cd3389a78..ab557794e709 100644 --- a/examples/pyplots/fig_axes_customize_simple.py +++ b/examples/pyplots/fig_axes_customize_simple.py @@ -23,5 +23,4 @@ line.set_markersize(25) line.set_markeredgewidth(3) - - +plt.show() diff --git a/examples/pyplots/fig_axes_labels_simple.py b/examples/pyplots/fig_axes_labels_simple.py index b59a9e780485..50b6dd65f3e8 100644 --- a/examples/pyplots/fig_axes_labels_simple.py +++ b/examples/pyplots/fig_axes_labels_simple.py @@ -19,4 +19,4 @@ facecolor='yellow', edgecolor='yellow') ax2.set_xlabel('time (s)') - +plt.show() diff --git a/examples/pyplots/fig_x.py b/examples/pyplots/fig_x.py index 1ab412949429..c573f2266303 100644 --- a/examples/pyplots/fig_x.py +++ b/examples/pyplots/fig_x.py @@ -1,6 +1,8 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib.lines as lines + + fig = plt.figure() l1 = lines.Line2D([0, 1], [0, 1], transform=fig.transFigure, figure=fig) @@ -9,4 +11,4 @@ fig.lines.extend([l1, l2]) - +plt.show() diff --git a/examples/pyplots/whats_new_99_spines.py b/examples/pyplots/whats_new_99_spines.py index 83c4edf5d07f..de95522f0622 100644 --- a/examples/pyplots/whats_new_99_spines.py +++ b/examples/pyplots/whats_new_99_spines.py @@ -1,6 +1,5 @@ import matplotlib.pyplot as plt import numpy as np -from matplotlib.pyplot import show def adjust_spines(ax,spines): @@ -44,4 +43,4 @@ def adjust_spines(ax,spines): ax.plot(x,y) adjust_spines(ax,['bottom']) -show() +plt.show() diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index d63415a380ee..9919c0d985fc 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -280,13 +280,10 @@ def test_pep8_conformance_examples(): '*/pyplots/tex_demo.py', '*/pyplots/compound_path_demo.py', '*/pyplots/text_commands.py', - '*/pyplots/dollar_ticks.py', '*/pyplots/text_layout.py', '*/pyplots/fig_axes_customize_simple.py', '*/pyplots/whats_new_1_subplot3d.py', - '*/pyplots/fig_axes_labels_simple.py', '*/pyplots/whats_new_98_4_fancy.py', - '*/pyplots/fig_x.py', '*/pyplots/whats_new_98_4_fill_between.py', '*/pyplots/whats_new_98_4_legend.py', '*/pyplots/pyplot_annotate.py', From f328fe62db0d8099b4bf44354f43c688673f8935 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 3 Dec 2016 21:44:11 -0500 Subject: [PATCH 03/11] Default alignment of bar is center -> fix examples. --- examples/api/barchart_demo.py | 2 +- examples/axes_grid/demo_floating_axes.py | 2 +- examples/pylab_examples/bar_stacked.py | 2 +- examples/pylab_examples/barchart_demo.py | 2 +- examples/pylab_examples/barchart_demo2.py | 2 +- examples/pylab_examples/custom_ticker1.py | 2 +- examples/pylab_examples/demo_agg_filter.py | 1 - examples/pylab_examples/log_bar.py | 3 ++- examples/pylab_examples/system_monitor.py | 6 ++---- examples/units/bar_unit_demo.py | 2 +- lib/matplotlib/axes/_axes.py | 2 +- 11 files changed, 12 insertions(+), 14 deletions(-) diff --git a/examples/api/barchart_demo.py b/examples/api/barchart_demo.py index 7a6960cd2ec6..f5111d945066 100644 --- a/examples/api/barchart_demo.py +++ b/examples/api/barchart_demo.py @@ -25,7 +25,7 @@ # add some text for labels, title and axes ticks ax.set_ylabel('Scores') ax.set_title('Scores by group and gender') -ax.set_xticks(ind + width) +ax.set_xticks(ind + width / 2) ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5')) ax.legend((rects1[0], rects2[0]), ('Men', 'Women')) diff --git a/examples/axes_grid/demo_floating_axes.py b/examples/axes_grid/demo_floating_axes.py index cf05e5b17405..f2b35f478b43 100644 --- a/examples/axes_grid/demo_floating_axes.py +++ b/examples/axes_grid/demo_floating_axes.py @@ -27,7 +27,7 @@ def setup_axes1(fig, rect): tr = Affine2D().scale(2, 1).rotate_deg(30) grid_helper = floating_axes.GridHelperCurveLinear( - tr, extremes=(0, 4, 0, 4)) + tr, extremes=(-0.5, 3.5, 0, 4)) ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper) fig.add_subplot(ax1) diff --git a/examples/pylab_examples/bar_stacked.py b/examples/pylab_examples/bar_stacked.py index d2fb3b94841b..67ef657a8eea 100755 --- a/examples/pylab_examples/bar_stacked.py +++ b/examples/pylab_examples/bar_stacked.py @@ -17,7 +17,7 @@ plt.ylabel('Scores') plt.title('Scores by group and gender') -plt.xticks(ind + width/2., ('G1', 'G2', 'G3', 'G4', 'G5')) +plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) plt.yticks(np.arange(0, 81, 10)) plt.legend((p1[0], p2[0]), ('Men', 'Women')) diff --git a/examples/pylab_examples/barchart_demo.py b/examples/pylab_examples/barchart_demo.py index 5d591f45cc90..071d6b788f30 100644 --- a/examples/pylab_examples/barchart_demo.py +++ b/examples/pylab_examples/barchart_demo.py @@ -38,7 +38,7 @@ plt.xlabel('Group') plt.ylabel('Scores') plt.title('Scores by group and gender') -plt.xticks(index + bar_width, ('A', 'B', 'C', 'D', 'E')) +plt.xticks(index + bar_width / 2, ('A', 'B', 'C', 'D', 'E')) plt.legend() plt.tight_layout() diff --git a/examples/pylab_examples/barchart_demo2.py b/examples/pylab_examples/barchart_demo2.py index 15a6aad415d2..939869235192 100644 --- a/examples/pylab_examples/barchart_demo2.py +++ b/examples/pylab_examples/barchart_demo2.py @@ -69,7 +69,7 @@ def plot_student_results(student, scores, cohort_size): fig.subplots_adjust(left=0.115, right=0.88) fig.canvas.set_window_title('Eldorado K-8 Fitness Chart') - pos = np.arange(len(testNames)) + 0.5 # Center bars on the Y-axis ticks + pos = np.arange(len(testNames)) rects = ax1.barh(pos, [scores[k].percentile for k in testNames], align='center', diff --git a/examples/pylab_examples/custom_ticker1.py b/examples/pylab_examples/custom_ticker1.py index dfd0fc847ff7..070d69e912ce 100755 --- a/examples/pylab_examples/custom_ticker1.py +++ b/examples/pylab_examples/custom_ticker1.py @@ -25,5 +25,5 @@ def millions(x, pos): fig, ax = plt.subplots() ax.yaxis.set_major_formatter(formatter) plt.bar(x, money) -plt.xticks(x + 0.5, ('Bill', 'Fred', 'Mary', 'Sue')) +plt.xticks(x, ('Bill', 'Fred', 'Mary', 'Sue')) plt.show() diff --git a/examples/pylab_examples/demo_agg_filter.py b/examples/pylab_examples/demo_agg_filter.py index 3337497675d2..785e8d6784c8 100644 --- a/examples/pylab_examples/demo_agg_filter.py +++ b/examples/pylab_examples/demo_agg_filter.py @@ -283,7 +283,6 @@ def drop_shadow_patches(ax): ax.add_artist(shadow) shadow.set_zorder(rects1[0].get_zorder() - 0.1) - ax.set_xlim(ind[0] - 0.5, ind[-1] + 1.5) ax.set_ylim(0, 40) ax.xaxis.set_visible(False) diff --git a/examples/pylab_examples/log_bar.py b/examples/pylab_examples/log_bar.py index 362b123ebaa4..40c11c49d70d 100644 --- a/examples/pylab_examples/log_bar.py +++ b/examples/pylab_examples/log_bar.py @@ -16,6 +16,7 @@ for i in range(len(data[0])): y = [d[i] for d in data] b = plt.bar(x + i * dimw, y, dimw, bottom=0.001) -plt.xticks(x + w / 2) + +plt.xticks(x + dimw / 2, map(str, x)) plt.show() diff --git a/examples/pylab_examples/system_monitor.py b/examples/pylab_examples/system_monitor.py index 55385e3cc0e2..38bd4bfc94de 100644 --- a/examples/pylab_examples/system_monitor.py +++ b/examples/pylab_examples/system_monitor.py @@ -29,14 +29,12 @@ def get_stats(t): pm, pc, pn = plt.bar(ind, get_stats(0)) -centers = ind + 0.5*pm.get_width() pm.set_facecolor('r') pc.set_facecolor('g') pn.set_facecolor('b') -ax.set_xlim([0.5, 4]) -ax.set_xticks(centers) -ax.set_ylim([0, 100]) +ax.set_xticks(ind) ax.set_xticklabels(['Memory', 'CPU', 'Bandwidth']) +ax.set_ylim([0, 100]) ax.set_ylabel('Percent usage') ax.set_title('System Monitor') diff --git a/examples/units/bar_unit_demo.py b/examples/units/bar_unit_demo.py index 86b2add9e28a..e544a63d7629 100644 --- a/examples/units/bar_unit_demo.py +++ b/examples/units/bar_unit_demo.py @@ -19,7 +19,7 @@ p2 = ax.bar(ind + width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) ax.set_title('Scores by group and gender') -ax.set_xticks(ind + width) +ax.set_xticks(ind + width / 2) ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5')) ax.legend((p1[0], p2[0]), ('Men', 'Women')) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index bcfaf7130cc8..87ce75628fee 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1922,7 +1922,7 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs): dictionary of kwargs to be passed to errorbar method. *ecolor* and *capsize* may be specified here rather than as independent kwargs. - align : {'edge', 'center'}, optional + align : {'center', 'edge'}, optional If 'edge', aligns bars by their left edges (for vertical bars) and by their bottom edges (for horizontal bars). If 'center', interpret the `left` argument as the coordinates of the centers of the bars. From 2b5c486a6ae77a1f725068b9225091c4e9afe831 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 3 Dec 2016 21:55:03 -0500 Subject: [PATCH 04/11] Fix mpl deprecations in examples. svg.embed_char_paths -> svg.fonttype axisbg -> facecolor Skip 'spectral' colormap in a demo. --- examples/pylab_examples/demo_bboximage.py | 1 + examples/user_interfaces/svg_histogram.py | 3 ++- examples/widgets/span_selector.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/demo_bboximage.py b/examples/pylab_examples/demo_bboximage.py index e8c2a412e705..0063da828c9d 100644 --- a/examples/pylab_examples/demo_bboximage.py +++ b/examples/pylab_examples/demo_bboximage.py @@ -26,6 +26,7 @@ a = np.vstack((a, a)) maps = sorted(m for m in plt.cm.cmap_d if not m.endswith("_r")) + maps.remove('spectral') # Deprecated. #nmaps = len(maps) + 1 #fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99) diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index fea08b8cd688..5e854cf44a02 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -35,7 +35,8 @@ from io import BytesIO import json -plt.rcParams['svg.embed_char_paths'] = 'none' + +plt.rcParams['svg.fonttype'] = 'none' # Apparently, this `register_namespace` method works only with # python 2.7 and up and is necessary to avoid garbling the XML name diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.py index d7bd5a1e426a..3b0f11e401c4 100755 --- a/examples/widgets/span_selector.py +++ b/examples/widgets/span_selector.py @@ -16,7 +16,7 @@ ax.set_ylim(-2, 2) ax.set_title('Press left mouse button and drag to test') -ax2 = fig.add_subplot(212, axisbg='#FFFFCC') +ax2 = fig.add_subplot(212, facecolor='#FFFFCC') line2, = ax2.plot(x, y, '-') From 41c5f9fb1350c71c1963ba0885c2cd08d9012cfd Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 3 Dec 2016 23:45:33 -0500 Subject: [PATCH 05/11] Fix NumPy warnings in some demos. --- examples/event_handling/lasso_demo.py | 3 +-- .../images_contours_and_fields/streamplot_demo_masking.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/event_handling/lasso_demo.py b/examples/event_handling/lasso_demo.py index 8cc8d662043d..09a03af24d89 100644 --- a/examples/event_handling/lasso_demo.py +++ b/examples/event_handling/lasso_demo.py @@ -38,9 +38,8 @@ def __init__(self, ax, data): facecolors = [d.color for d in data] self.xys = [(d.x, d.y) for d in data] - fig = ax.figure self.collection = RegularPolyCollection( - fig.dpi, 6, sizes=(100,), + 6, sizes=(100,), facecolors=facecolors, offsets=self.xys, transOffset=ax.transData) diff --git a/examples/images_contours_and_fields/streamplot_demo_masking.py b/examples/images_contours_and_fields/streamplot_demo_masking.py index 809d13b002fa..4188622989d0 100644 --- a/examples/images_contours_and_fields/streamplot_demo_masking.py +++ b/examples/images_contours_and_fields/streamplot_demo_masking.py @@ -14,9 +14,9 @@ speed = np.sqrt(U*U + V*V) mask = np.zeros(U.shape, dtype=bool) -mask[40:60, 40:60] = 1 -U = np.ma.array(U, mask=mask) +mask[40:60, 40:60] = True U[:20, :20] = np.nan +U = np.ma.array(U, mask=mask) fig, ax = plt.subplots() ax.streamplot(X, Y, U, V, color='r') From e30af98ce89e606b0cc3f0dcc56469d035afba8f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 4 Dec 2016 00:03:31 -0500 Subject: [PATCH 06/11] Fix print_stdout example on Python 3. --- examples/pylab_examples/print_stdout.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/print_stdout.py b/examples/pylab_examples/print_stdout.py index a5725888e4e6..d08205f4508e 100644 --- a/examples/pylab_examples/print_stdout.py +++ b/examples/pylab_examples/print_stdout.py @@ -9,5 +9,7 @@ plt.plot([1, 2, 3]) -plt.savefig(sys.stdout) -plt.show() +if sys.version_info[0] >= 3: + plt.savefig(sys.stdout.buffer) +else: + plt.savefig(sys.stdout) From e6ce528876f9f8d6fa95e0da0dfe9225fc9e7940 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 4 Dec 2016 00:06:27 -0500 Subject: [PATCH 07/11] "Press any key" -> "Press Enter" because of input(). input() does not return until you press Enter, so be explicit about it. --- examples/widgets/lasso_selector_demo.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/widgets/lasso_selector_demo.py b/examples/widgets/lasso_selector_demo.py index 4d1de112f731..3f5b47fa81f5 100644 --- a/examples/widgets/lasso_selector_demo.py +++ b/examples/widgets/lasso_selector_demo.py @@ -1,16 +1,12 @@ from __future__ import print_function +from six.moves import input + import numpy as np from matplotlib.widgets import LassoSelector from matplotlib.path import Path -try: - raw_input -except NameError: - # Python 3 - raw_input = input - class SelectFromCollection(object): """Select indices from a matplotlib collection using `LassoSelector`. @@ -81,10 +77,10 @@ def disconnect(self): selector = SelectFromCollection(ax, pts) plt.draw() - raw_input('Press any key to accept selected points') + input('Press Enter to accept selected points') print("Selected points:") print(selector.xys[selector.ind]) selector.disconnect() # Block end of script so you can check that the lasso is disconnected. - raw_input('Press any key to quit') + input('Press Enter to quit') From 33873c51d581e03d98340bc718e835f0e304ad88 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 4 Dec 2016 00:08:53 -0500 Subject: [PATCH 08/11] Tweak layout of tick examples. Move the large label closer to the bottom spine so it appears related; remove extra whitespace around the figure. --- examples/ticks_and_spines/tick-formatters.py | 18 +++++++++------- examples/ticks_and_spines/tick-locators.py | 22 ++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/examples/ticks_and_spines/tick-formatters.py b/examples/ticks_and_spines/tick-formatters.py index e4278d41c631..19b486de69e9 100644 --- a/examples/ticks_and_spines/tick-formatters.py +++ b/examples/ticks_and_spines/tick-formatters.py @@ -21,7 +21,7 @@ def setup(ax): ax.patch.set_alpha(0.0) -plt.figure(figsize=(8, 6)) +plt.figure(figsize=(8, 5)) n = 6 # Null formatter @@ -31,7 +31,7 @@ def setup(ax): ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25)) ax.xaxis.set_major_formatter(ticker.NullFormatter()) ax.xaxis.set_minor_formatter(ticker.NullFormatter()) -ax.text(0.0, 0.5, "NullFormatter()", fontsize=16, transform=ax.transAxes) +ax.text(0.0, 0.1, "NullFormatter()", fontsize=16, transform=ax.transAxes) # Fixed formatter ax = plt.subplot(n, 1, 2) @@ -43,7 +43,7 @@ def setup(ax): minors = [""] + ["%.2f" % (x-int(x)) if (x-int(x)) else "" for x in np.arange(0, 5, 0.25)] ax.xaxis.set_minor_formatter(ticker.FixedFormatter(minors)) -ax.text(0.0, 0.5, "FixedFormatter(['', '0', '1', ...])", +ax.text(0.0, 0.1, "FixedFormatter(['', '0', '1', ...])", fontsize=15, transform=ax.transAxes) @@ -57,7 +57,7 @@ def major_formatter(x, pos): ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00)) ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25)) ax.xaxis.set_major_formatter(ticker.FuncFormatter(major_formatter)) -ax.text(0.0, 0.5, 'FuncFormatter(lambda x, pos: "[%.2f]" % x)', +ax.text(0.0, 0.1, 'FuncFormatter(lambda x, pos: "[%.2f]" % x)', fontsize=15, transform=ax.transAxes) @@ -67,7 +67,7 @@ def major_formatter(x, pos): ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00)) ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25)) ax.xaxis.set_major_formatter(ticker.FormatStrFormatter(">%d<")) -ax.text(0.0, 0.5, "FormatStrFormatter('>%d<')", +ax.text(0.0, 0.1, "FormatStrFormatter('>%d<')", fontsize=15, transform=ax.transAxes) # Scalar formatter @@ -76,7 +76,7 @@ def major_formatter(x, pos): ax.xaxis.set_major_locator(ticker.AutoLocator()) ax.xaxis.set_minor_locator(ticker.AutoMinorLocator()) ax.xaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=True)) -ax.text(0.0, 0.5, "ScalarFormatter()", fontsize=15, transform=ax.transAxes) +ax.text(0.0, 0.1, "ScalarFormatter()", fontsize=15, transform=ax.transAxes) # StrMethod formatter ax = plt.subplot(n, 1, 6) @@ -84,7 +84,11 @@ def major_formatter(x, pos): ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00)) ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25)) ax.xaxis.set_major_formatter(ticker.StrMethodFormatter("{x}")) -ax.text(0.0, 0.5, "StrMethodFormatter('{x}')", +ax.text(0.0, 0.1, "StrMethodFormatter('{x}')", fontsize=15, transform=ax.transAxes) +# Push the top of the top axes outside the figure because we only show the +# bottom spine. +plt.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=1.05) + plt.show() diff --git a/examples/ticks_and_spines/tick-locators.py b/examples/ticks_and_spines/tick-locators.py index 2add8a29a543..c9d0dc6cb437 100644 --- a/examples/ticks_and_spines/tick-locators.py +++ b/examples/ticks_and_spines/tick-locators.py @@ -23,7 +23,7 @@ def setup(ax): ax.patch.set_alpha(0.0) -plt.figure(figsize=(8, 8)) +plt.figure(figsize=(8, 6)) n = 8 # Null Locator @@ -31,14 +31,14 @@ def setup(ax): setup(ax) ax.xaxis.set_major_locator(ticker.NullLocator()) ax.xaxis.set_minor_locator(ticker.NullLocator()) -ax.text(0.0, 0.5, "NullLocator()", fontsize=14, transform=ax.transAxes) +ax.text(0.0, 0.1, "NullLocator()", fontsize=14, transform=ax.transAxes) # Multiple Locator ax = plt.subplot(n, 1, 2) setup(ax) ax.xaxis.set_major_locator(ticker.MultipleLocator(0.5)) ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.1)) -ax.text(0.0, 0.5, "MultipleLocator(0.5)", fontsize=14, +ax.text(0.0, 0.1, "MultipleLocator(0.5)", fontsize=14, transform=ax.transAxes) # Fixed Locator @@ -48,7 +48,7 @@ def setup(ax): ax.xaxis.set_major_locator(ticker.FixedLocator(majors)) minors = np.linspace(0, 1, 11)[1:-1] ax.xaxis.set_minor_locator(ticker.FixedLocator(minors)) -ax.text(0.0, 0.5, "FixedLocator([0, 1, 5])", fontsize=14, +ax.text(0.0, 0.1, "FixedLocator([0, 1, 5])", fontsize=14, transform=ax.transAxes) # Linear Locator @@ -56,7 +56,7 @@ def setup(ax): setup(ax) ax.xaxis.set_major_locator(ticker.LinearLocator(3)) ax.xaxis.set_minor_locator(ticker.LinearLocator(31)) -ax.text(0.0, 0.5, "LinearLocator(numticks=3)", +ax.text(0.0, 0.1, "LinearLocator(numticks=3)", fontsize=14, transform=ax.transAxes) # Index Locator @@ -64,7 +64,7 @@ def setup(ax): setup(ax) ax.plot(range(0, 5), [0]*5, color='White') ax.xaxis.set_major_locator(ticker.IndexLocator(base=.5, offset=.25)) -ax.text(0.0, 0.5, "IndexLocator(base=0.5, offset=0.25)", +ax.text(0.0, 0.1, "IndexLocator(base=0.5, offset=0.25)", fontsize=14, transform=ax.transAxes) # Auto Locator @@ -72,14 +72,14 @@ def setup(ax): setup(ax) ax.xaxis.set_major_locator(ticker.AutoLocator()) ax.xaxis.set_minor_locator(ticker.AutoMinorLocator()) -ax.text(0.0, 0.5, "AutoLocator()", fontsize=14, transform=ax.transAxes) +ax.text(0.0, 0.1, "AutoLocator()", fontsize=14, transform=ax.transAxes) # MaxN Locator ax = plt.subplot(n, 1, 7) setup(ax) ax.xaxis.set_major_locator(ticker.MaxNLocator(4)) ax.xaxis.set_minor_locator(ticker.MaxNLocator(40)) -ax.text(0.0, 0.5, "MaxNLocator(n=4)", fontsize=14, transform=ax.transAxes) +ax.text(0.0, 0.1, "MaxNLocator(n=4)", fontsize=14, transform=ax.transAxes) # Log Locator ax = plt.subplot(n, 1, 8) @@ -87,7 +87,11 @@ def setup(ax): ax.set_xlim(10**3, 10**10) ax.set_xscale('log') ax.xaxis.set_major_locator(ticker.LogLocator(base=10.0, numticks=15)) -ax.text(0.0, 0.5, "LogLocator(base=10, numticks=15)", +ax.text(0.0, 0.1, "LogLocator(base=10, numticks=15)", fontsize=15, transform=ax.transAxes) +# Push the top of the top axes outside the figure because we only show the +# bottom spine. +plt.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=1.05) + plt.show() From 28b8040b1e96107514fbfc3025f071b5884cd903 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 4 Dec 2016 02:20:13 -0500 Subject: [PATCH 09/11] Use anchor rotation_mode in text rotation example. This keeps the location in a relatively normal place. Also, fix the text to actually be different between the two objects. --- examples/pylab_examples/text_rotation_relative_to_line.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/pylab_examples/text_rotation_relative_to_line.py b/examples/pylab_examples/text_rotation_relative_to_line.py index d27897c6d4cc..a6c2f7c80579 100644 --- a/examples/pylab_examples/text_rotation_relative_to_line.py +++ b/examples/pylab_examples/text_rotation_relative_to_line.py @@ -26,12 +26,12 @@ # Rotate angle angle = 45 trans_angle = plt.gca().transData.transform_angles(np.array((45,)), - l2.reshape((1, 2)))[0] + l2.reshape((1, 2)))[0] # Plot text th1 = plt.text(l1[0], l1[1], 'text not rotated correctly', fontsize=16, - rotation=angle) -th2 = plt.text(l2[0], l2[1], 'text not rotated correctly', fontsize=16, - rotation=trans_angle) + rotation=angle, rotation_mode='anchor') +th2 = plt.text(l2[0], l2[1], 'text rotated correctly', fontsize=16, + rotation=trans_angle, rotation_mode='anchor') plt.show() From 7de832cab101c3e615061ce92ba974f95f7eb6ce Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 4 Dec 2016 02:21:43 -0500 Subject: [PATCH 10/11] Fix several minor typos in examples. --- .../axes_grid/figures/simple_axisartist1.py | 2 +- doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py | 2 +- doc/users/plotting/examples/custom_boxstyle02.py | 2 +- examples/api/date_demo.py | 2 +- examples/api/font_file.py | 2 +- examples/api/histogram_path_demo.py | 2 +- examples/api/radar_chart.py | 2 +- examples/api/unicode_minus.py | 8 ++++---- examples/axes_grid/demo_curvelinear_grid.py | 2 +- examples/axes_grid/demo_parasite_axes2.py | 2 +- examples/event_handling/README.txt | 2 +- examples/event_handling/legend_picking.py | 2 +- examples/event_handling/viewlims.py | 4 ++-- examples/misc/ftface_props.py | 4 ++-- examples/misc/sample_data_demo.py | 2 +- examples/misc/svg_filter_line.py | 4 ++-- examples/misc/svg_filter_pie.py | 10 +++++----- examples/pylab_examples/accented_text.py | 2 +- examples/pylab_examples/centered_ticklabels.py | 2 +- examples/pylab_examples/demo_agg_filter.py | 2 +- examples/pylab_examples/errorbar_subsample.py | 2 +- examples/pylab_examples/leftventricle_bulleye.py | 2 +- examples/pylab_examples/pythonic_matplotlib.py | 4 ++-- examples/pylab_examples/scatter_demo2.py | 2 +- examples/pylab_examples/scatter_masked.py | 2 +- examples/pylab_examples/system_monitor.py | 2 +- examples/pylab_examples/tricontour_smooth_delaunay.py | 4 ++-- examples/pylab_examples/webapp_demo.py | 2 +- examples/shapes_and_collections/scatter_demo.py | 2 +- examples/specialty_plots/topographic_hillshading.py | 2 +- examples/statistics/histogram_demo_cumulative.py | 2 +- examples/statistics/violinplot_demo.py | 2 +- examples/units/units_sample.py | 2 +- examples/user_interfaces/README.wx | 2 +- examples/user_interfaces/embedding_in_tk_canvas.py | 2 +- examples/user_interfaces/svg_histogram.py | 8 ++++---- examples/user_interfaces/svg_tooltip.py | 2 +- examples/widgets/README.txt | 2 +- examples/widgets/rectangle_selector.py | 4 ++-- 39 files changed, 55 insertions(+), 55 deletions(-) diff --git a/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py b/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py index 6093ea205b6b..d9a8a69094e0 100644 --- a/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py +++ b/doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py @@ -10,7 +10,7 @@ ax.axis["bottom", "top", "right"].set_visible(False) # make an new axis along the first axis axis (x-axis) which pass -# throught y=0. +# through y=0. ax.axis["y=0"] = ax.new_floating_axis(nth_coord=0, value=0, axis_direction="bottom") ax.axis["y=0"].toggle(all=True) diff --git a/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py b/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py index 5440aec168a1..9aa59dd98ce4 100644 --- a/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py +++ b/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py @@ -4,7 +4,7 @@ fig = plt.figure(1, (4,3)) -# a subplot with two additiona axis, "xzero" and "yzero". "xzero" is +# a subplot with two additional axis, "xzero" and "yzero". "xzero" is # y=0 line, and "yzero" is x=0 line. ax = SubplotZero(fig, 1, 1, 1) fig.add_subplot(ax) diff --git a/doc/users/plotting/examples/custom_boxstyle02.py b/doc/users/plotting/examples/custom_boxstyle02.py index 96933cb06897..bd6616c8158c 100644 --- a/doc/users/plotting/examples/custom_boxstyle02.py +++ b/doc/users/plotting/examples/custom_boxstyle02.py @@ -3,7 +3,7 @@ import matplotlib.pyplot as plt # we may derive from matplotlib.patches.BoxStyle._Base class. -# You need to overide transmute method in this case. +# You need to override transmute method in this case. class MyStyle(BoxStyle._Base): """ diff --git a/examples/api/date_demo.py b/examples/api/date_demo.py index 99227572e5cd..96635387706c 100644 --- a/examples/api/date_demo.py +++ b/examples/api/date_demo.py @@ -31,7 +31,7 @@ datafile = cbook.get_sample_data('goog.npy') try: # Python3 cannot load python2 .npy files with datetime(object) arrays - # unless the encoding is set to bytes. Hovever this option was + # unless the encoding is set to bytes. However this option was # not added until numpy 1.10 so this example will only work with # python 2 or with numpy 1.10 and later. r = np.load(datafile, encoding='bytes').view(np.recarray) diff --git a/examples/api/font_file.py b/examples/api/font_file.py index 1d678ad521d6..d35e50dae160 100644 --- a/examples/api/font_file.py +++ b/examples/api/font_file.py @@ -7,7 +7,7 @@ Although it is usually not a good idea to explicitly point to a single ttf file for a font instance, you can do so using the font_manager.FontProperties fname argument (for a more flexible -solution, see the font_fmaily_rc.py and fonts_demo.py examples). +solution, see the font_family_rc.py and fonts_demo.py examples). """ import sys import os diff --git a/examples/api/histogram_path_demo.py b/examples/api/histogram_path_demo.py index 13f49b551e62..431252652a44 100644 --- a/examples/api/histogram_path_demo.py +++ b/examples/api/histogram_path_demo.py @@ -8,7 +8,7 @@ the faster method of using PolyCollections, were implemented before we had proper paths with moveto/lineto, closepoly etc in mpl. Now that we have them, we can draw collections of regularly shaped objects with -homogeous properties more efficiently with a PathCollection. This +homogeneous properties more efficiently with a PathCollection. This example makes a histogram -- its more work to set up the vertex arrays at the outset, but it should be much faster for large numbers of objects diff --git a/examples/api/radar_chart.py b/examples/api/radar_chart.py index 8439e75741f8..2660f56f6f2a 100644 --- a/examples/api/radar_chart.py +++ b/examples/api/radar_chart.py @@ -135,7 +135,7 @@ def example_data(): # Pyrolized Organic Carbon (OP) # 2)Inclusion of gas-phase specie carbon monoxide (CO) # 3)Inclusion of gas-phase specie ozone (O3). - # 4)Inclusion of both gas-phase speciesis present... + # 4)Inclusion of both gas-phase species is present... data = [ ['Sulfate', 'Nitrate', 'EC', 'OC1', 'OC2', 'OC3', 'OP', 'CO', 'O3'], ('Basecase', [ diff --git a/examples/api/unicode_minus.py b/examples/api/unicode_minus.py index cf413d2e9129..fcebab8e1f3b 100644 --- a/examples/api/unicode_minus.py +++ b/examples/api/unicode_minus.py @@ -3,12 +3,12 @@ Unicode minus ============= -You can use the proper typesetting unicode minus (see -http://en.wikipedia.org/wiki/Plus_sign#Plus_sign) or the ASCII hypen +You can use the proper typesetting Unicode minus (see +https://en.wikipedia.org/wiki/Plus_sign#Plus_sign) or the ASCII hyphen for minus, which some people prefer. The matplotlibrc param axes.unicode_minus controls the default behavior. -The default is to use the unicode minus +The default is to use the Unicode minus. """ import numpy as np import matplotlib @@ -17,5 +17,5 @@ matplotlib.rcParams['axes.unicode_minus'] = False fig, ax = plt.subplots() ax.plot(10*np.random.randn(100), 10*np.random.randn(100), 'o') -ax.set_title('Using hypen instead of unicode minus') +ax.set_title('Using hyphen instead of Unicode minus') plt.show() diff --git a/examples/axes_grid/demo_curvelinear_grid.py b/examples/axes_grid/demo_curvelinear_grid.py index 433ec46f2d39..ad8d0f51e81a 100644 --- a/examples/axes_grid/demo_curvelinear_grid.py +++ b/examples/axes_grid/demo_curvelinear_grid.py @@ -113,7 +113,7 @@ def curvelinear_test2(fig): # A parasite axes with given transform ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal") # note that ax2.transData == tr + ax1.transData - # Anthing you draw in ax2 will match the ticks and grids of ax1. + # Anything you draw in ax2 will match the ticks and grids of ax1. ax1.parasites.append(ax2) intp = cbook.simple_linear_interpolation ax2.plot(intp(np.array([0, 30]), 50), diff --git a/examples/axes_grid/demo_parasite_axes2.py b/examples/axes_grid/demo_parasite_axes2.py index 2cd377187b53..e4053ef0a071 100644 --- a/examples/axes_grid/demo_parasite_axes2.py +++ b/examples/axes_grid/demo_parasite_axes2.py @@ -5,7 +5,7 @@ to plot multiple different values onto one single plot. Notice how in this example, par1 and par2 are both calling twinx meaning both are tied directly to the x-axis. From there, each of those two axis can behave separately from the -each other, meaning they can take on seperate values from themselves as well as +each other, meaning they can take on separate values from themselves as well as the x-axis. """ from mpl_toolkits.axes_grid1 import host_subplot diff --git a/examples/event_handling/README.txt b/examples/event_handling/README.txt index 66068d6ce41a..0531adc749f7 100644 --- a/examples/event_handling/README.txt +++ b/examples/event_handling/README.txt @@ -5,7 +5,7 @@ matplotlib supports event handling with a GUI neutral event model. So you can connect to matplotlib events w/o knowledge of what user interface matplotlib will ultimately be plugged in to. This has two advantages: the code you write will be more portable, and matplotlib -events are aware of things like data coordinate space and whih axes +events are aware of things like data coordinate space and which axes the event occurs in so you don't have to mess with low level transformation details to go from canvas space to data space. Object picking examples are also included. diff --git a/examples/event_handling/legend_picking.py b/examples/event_handling/legend_picking.py index 1c37ad3c6e85..88641554b70b 100644 --- a/examples/event_handling/legend_picking.py +++ b/examples/event_handling/legend_picking.py @@ -1,5 +1,5 @@ """ -Enable picking on the legend to toggle the legended line on and off +Enable picking on the legend to toggle the original line on and off """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/event_handling/viewlims.py b/examples/event_handling/viewlims.py index 18dba5e21b08..c1c0230cf7d6 100644 --- a/examples/event_handling/viewlims.py +++ b/examples/event_handling/viewlims.py @@ -17,7 +17,7 @@ def __call__(self, ax): # A class that will regenerate a fractal set as we zoom in, so that you # can actually see the increasing detail. A box in the left panel will show # the area to which we are zoomed. -class MandlebrotDisplay(object): +class MandelbrotDisplay(object): def __init__(self, h=500, w=500, niter=50, radius=2., power=2): self.height = h self.width = w @@ -57,7 +57,7 @@ def ax_update(self, ax): im.set_extent((xstart, xend, ystart, yend)) ax.figure.canvas.draw_idle() -md = MandlebrotDisplay() +md = MandelbrotDisplay() Z = md(-2., 0.5, -1.25, 1.25) fig1, (ax1, ax2) = plt.subplots(1, 2) diff --git a/examples/misc/ftface_props.py b/examples/misc/ftface_props.py index c39ca5d69814..c00f382763a1 100755 --- a/examples/misc/ftface_props.py +++ b/examples/misc/ftface_props.py @@ -2,7 +2,7 @@ """ This is a demo script to show you how to use all the properties of an FT2Font object. These describe global font properties. For -individual character metrices, use the Glyp object, as returned by +individual character metrics, use the Glyph object, as returned by load_char """ import matplotlib @@ -18,7 +18,7 @@ print('Num faces :', font.num_faces) # number of faces in file print('Num glyphs :', font.num_glyphs) # number of glyphs in the face print('Family name :', font.family_name) # face family name -print('Syle name :', font.style_name) # face syle name +print('Style name :', font.style_name) # face style name print('PS name :', font.postscript_name) # the postscript name print('Num fixed :', font.num_fixed_sizes) # number of embedded bitmap in face diff --git a/examples/misc/sample_data_demo.py b/examples/misc/sample_data_demo.py index 1e60b1e90854..082fb63d6050 100644 --- a/examples/misc/sample_data_demo.py +++ b/examples/misc/sample_data_demo.py @@ -1,6 +1,6 @@ """ Grab mpl data from the ~/.matplotlib/sample_data cache if it exists, else -fetch it from github and cache it +fetch it from GitHub and cache it """ from __future__ import print_function import matplotlib.cbook as cbook diff --git a/examples/misc/svg_filter_line.py b/examples/misc/svg_filter_line.py index 006ca04b6a85..198e673b78fb 100644 --- a/examples/misc/svg_filter_line.py +++ b/examples/misc/svg_filter_line.py @@ -1,7 +1,7 @@ """ Demonstrate SVG filtering effects which might be used with mpl. -Note that the filtering effects are only effective if your svg rederer +Note that the filtering effects are only effective if your svg renderer support it. """ @@ -78,7 +78,7 @@ for l in [l1, l2]: # pick up the svg element with given id shadow = xmlid[l.get_label() + "_shadow"] - # apply shdow filter + # apply shadow filter shadow.set("filter", 'url(#dropshadow)') fn = "svg_filter_line.svg" diff --git a/examples/misc/svg_filter_pie.py b/examples/misc/svg_filter_pie.py index 61a2719fce42..85f7d4b55bd7 100644 --- a/examples/misc/svg_filter_pie.py +++ b/examples/misc/svg_filter_pie.py @@ -2,7 +2,7 @@ Demonstrate SVG filtering effects which might be used with mpl. The pie chart drawing code is borrowed from pie_demo.py -Note that the filtering effects are only effective if your svg rederer +Note that the filtering effects are only effective if your svg renderer support it. """ @@ -50,12 +50,12 @@ # filter definition for shadow using a gaussian blur -# and lighteneing effect. -# The lightnening filter is copied from http://www.w3.org/TR/SVG/filters.html +# and lightening effect. +# The lightening filter is copied from http://www.w3.org/TR/SVG/filters.html # I tested it with Inkscape and Firefox3. "Gaussian blur" is supported -# in both, but the lightnening effect only in the inkscape. Also note -# that, inkscape's exporting also may not support it. +# in both, but the lightening effect only in the Inkscape. Also note +# that, Inkscape's exporting also may not support it. filter_def = """ diff --git a/examples/pylab_examples/accented_text.py b/examples/pylab_examples/accented_text.py index 1902ad71b480..16733a8060a4 100644 --- a/examples/pylab_examples/accented_text.py +++ b/examples/pylab_examples/accented_text.py @@ -1,4 +1,4 @@ -""" +r""" matplotlib supports accented characters via TeX mathtext The following accents are provided: \hat, \breve, \grave, \bar, diff --git a/examples/pylab_examples/centered_ticklabels.py b/examples/pylab_examples/centered_ticklabels.py index e745acf965bc..fbd7b1fd3fec 100644 --- a/examples/pylab_examples/centered_ticklabels.py +++ b/examples/pylab_examples/centered_ticklabels.py @@ -22,7 +22,7 @@ fh = cbook.get_sample_data('aapl.npy.gz') try: # Python3 cannot load python2 .npy files with datetime(object) arrays - # unless the encoding is set to bytes. Hovever this option was + # unless the encoding is set to bytes. However this option was # not added until numpy 1.10 so this example will only work with # python 2 or with numpy 1.10 and later. r = np.load(fh, encoding='bytes') diff --git a/examples/pylab_examples/demo_agg_filter.py b/examples/pylab_examples/demo_agg_filter.py index 785e8d6784c8..e4dbeb5c4b4d 100644 --- a/examples/pylab_examples/demo_agg_filter.py +++ b/examples/pylab_examples/demo_agg_filter.py @@ -265,7 +265,7 @@ def drop_shadow_line(ax): def drop_shadow_patches(ax): - # copyed from barchart_demo.py + # Copied from barchart_demo.py N = 5 menMeans = (20, 35, 30, 35, 27) diff --git a/examples/pylab_examples/errorbar_subsample.py b/examples/pylab_examples/errorbar_subsample.py index 6b21a36d4920..58ac3b1d3479 100644 --- a/examples/pylab_examples/errorbar_subsample.py +++ b/examples/pylab_examples/errorbar_subsample.py @@ -25,6 +25,6 @@ ax.set_title('only every 5th errorbar') -fig.suptitle('Errorbar subsampling for better visualibility') +fig.suptitle('Errorbar subsampling for better appearance') plt.show() diff --git a/examples/pylab_examples/leftventricle_bulleye.py b/examples/pylab_examples/leftventricle_bulleye.py index e96a4cc8e7f8..8a2442e3b0c6 100644 --- a/examples/pylab_examples/leftventricle_bulleye.py +++ b/examples/pylab_examples/leftventricle_bulleye.py @@ -62,7 +62,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None): theta_i = i*60*np.pi/180 ax.plot([theta_i, theta_i], [r[1], 1], '-k', lw=linewidth) - # Create the bounds for the segmentss 13-16 + # Create the bounds for the segments 13-16 for i in range(4): theta_i = i*90*np.pi/180 - 45*np.pi/180 ax.plot([theta_i, theta_i], [r[0], r[1]], '-k', lw=linewidth) diff --git a/examples/pylab_examples/pythonic_matplotlib.py b/examples/pylab_examples/pythonic_matplotlib.py index 5afdaabac68d..b868488f3eaf 100644 --- a/examples/pylab_examples/pythonic_matplotlib.py +++ b/examples/pylab_examples/pythonic_matplotlib.py @@ -8,7 +8,7 @@ show commands. These hide a lot of complexity from you that you don't need to see in normal figure creation, like instantiating DPI instances, managing the bounding boxes of the figure elements, -creating and reaslizing GUI windows and embedding figures in them. +creating and realizing GUI windows and embedding figures in them. If you are an application developer and want to embed matplotlib in @@ -19,7 +19,7 @@ If you are a web application developer, you may want to use the example in webapp_demo.py, which shows how to use the backend agg -figure canvase directly, with none of the globals (current figure, +figure canvas directly, with none of the globals (current figure, current axes) that are present in the pyplot interface. Note that there is no reason why the pyplot interface won't work for web application developers, however. diff --git a/examples/pylab_examples/scatter_demo2.py b/examples/pylab_examples/scatter_demo2.py index a4bca3a4b372..7632eb2cdac6 100644 --- a/examples/pylab_examples/scatter_demo2.py +++ b/examples/pylab_examples/scatter_demo2.py @@ -12,7 +12,7 @@ datafile = cbook.get_sample_data('goog.npy') try: # Python3 cannot load python2 .npy files with datetime(object) arrays - # unless the encoding is set to bytes. Hovever this option was + # unless the encoding is set to bytes. However this option was # not added until numpy 1.10 so this example will only work with # python 2 or with numpy 1.10 and later price_data = np.load(datafile, encoding='bytes').view(np.recarray) diff --git a/examples/pylab_examples/scatter_masked.py b/examples/pylab_examples/scatter_masked.py index 77c1c6299208..0bb9581a4386 100644 --- a/examples/pylab_examples/scatter_masked.py +++ b/examples/pylab_examples/scatter_masked.py @@ -5,7 +5,7 @@ r0 = 0.6 x = 0.9*np.random.rand(N) y = 0.9*np.random.rand(N) -area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radiuses +area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radii c = np.sqrt(area) r = np.sqrt(x*x + y*y) area1 = np.ma.masked_where(r < r0, area) diff --git a/examples/pylab_examples/system_monitor.py b/examples/pylab_examples/system_monitor.py index 38bd4bfc94de..8695bec5e6da 100644 --- a/examples/pylab_examples/system_monitor.py +++ b/examples/pylab_examples/system_monitor.py @@ -55,7 +55,7 @@ def get_stats(t): try: # make sure that the GUI framework has a chance to run its event loop # and clear any GUI events. This needs to be in a try/except block - # because the default implemenation of this method is to raise + # because the default implementation of this method is to raise # NotImplementedError fig.canvas.flush_events() except NotImplementedError: diff --git a/examples/pylab_examples/tricontour_smooth_delaunay.py b/examples/pylab_examples/tricontour_smooth_delaunay.py index a155347dcb90..4b5ca1a31437 100644 --- a/examples/pylab_examples/tricontour_smooth_delaunay.py +++ b/examples/pylab_examples/tricontour_smooth_delaunay.py @@ -113,10 +113,10 @@ def experiment_res(x, y): plt.title("Filtering a Delaunay mesh\n" + "(application to high-resolution tricontouring)") -# 1) plot of the refined (computed) data countours: +# 1) plot of the refined (computed) data contours: plt.tricontour(tri_refi, z_test_refi, levels=levels, cmap=cmap, linewidths=[2.0, 0.5, 1.0, 0.5]) -# 2) plot of the expected (analytical) data countours (dashed): +# 2) plot of the expected (analytical) data contours (dashed): if plot_expected: plt.tricontour(tri_refi, z_expected, levels=levels, cmap=cmap, linestyles='--') diff --git a/examples/pylab_examples/webapp_demo.py b/examples/pylab_examples/webapp_demo.py index 654e1e8ebfa7..273fcbd70ed7 100644 --- a/examples/pylab_examples/webapp_demo.py +++ b/examples/pylab_examples/webapp_demo.py @@ -36,7 +36,7 @@ def make_fig(): # make a translucent scatter collection x = np.random.rand(100) y = np.random.rand(100) - area = np.pi * (10 * np.random.rand(100)) ** 2 # 0 to 10 point radiuses + area = np.pi * (10 * np.random.rand(100)) ** 2 # 0 to 10 point radii c = ax.scatter(x, y, area) c.set_alpha(0.5) diff --git a/examples/shapes_and_collections/scatter_demo.py b/examples/shapes_and_collections/scatter_demo.py index 8e66dbfb1560..8fff9182ccd4 100644 --- a/examples/shapes_and_collections/scatter_demo.py +++ b/examples/shapes_and_collections/scatter_demo.py @@ -9,7 +9,7 @@ x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) -area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses +area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii plt.scatter(x, y, s=area, c=colors, alpha=0.5) plt.show() diff --git a/examples/specialty_plots/topographic_hillshading.py b/examples/specialty_plots/topographic_hillshading.py index 751ea6fe93c7..3ca750b5604e 100644 --- a/examples/specialty_plots/topographic_hillshading.py +++ b/examples/specialty_plots/topographic_hillshading.py @@ -24,7 +24,7 @@ # If you need topographically accurate vertical exaggeration, or you don't want # to guess at what *vert_exag* should be, you'll need to specify the cellsize # of the grid (i.e. the *dx* and *dy* parameters). Otherwise, any *vert_exag* -# value you specify will be realitive to the grid spacing of your input data +# value you specify will be relative to the grid spacing of your input data # (in other words, *dx* and *dy* default to 1.0, and *vert_exag* is calculated # relative to those parameters). Similarly, *dx* and *dy* are assumed to be in # the same units as your input z-values. Therefore, we'll need to convert the diff --git a/examples/statistics/histogram_demo_cumulative.py b/examples/statistics/histogram_demo_cumulative.py index e5918684e2f2..1e8f76cff8a6 100644 --- a/examples/statistics/histogram_demo_cumulative.py +++ b/examples/statistics/histogram_demo_cumulative.py @@ -48,7 +48,7 @@ fig, ax = plt.subplots(figsize=(8, 4)) -# plot the cumulative histograme +# plot the cumulative histogram n, bins, patches = ax.hist(x, n_bins, normed=1, histtype='step', cumulative=True, label='Empirical') diff --git a/examples/statistics/violinplot_demo.py b/examples/statistics/violinplot_demo.py index 5aaf8ea7699a..fdd30e980787 100644 --- a/examples/statistics/violinplot_demo.py +++ b/examples/statistics/violinplot_demo.py @@ -8,7 +8,7 @@ sample. Rather than showing counts of data points that fall into bins or order statistics, violin plots use kernel density estimation (KDE) to compute an empirical distribution of the sample. That computation -is controlled by several parameters. This example demostrates how to +is controlled by several parameters. This example demonstrates how to modify the number of points at which the KDE is evaluated (``points``) and how to modify the band-width of the KDE (``bw_method``). diff --git a/examples/units/units_sample.py b/examples/units/units_sample.py index 84f26490a87f..95be1bbef3e6 100644 --- a/examples/units/units_sample.py +++ b/examples/units/units_sample.py @@ -1,6 +1,6 @@ """ plot using a variety of cm vs inches conversions. The example shows -how default unit instrospection works (ax1), how various keywords can +how default unit introspection works (ax1), how various keywords can be used to set the x and y units to override the defaults (ax2, ax3, ax4) and how one can set the xlimits using scalars (ax3, current units assumed) or units (conversions applied to get the numbers to current diff --git a/examples/user_interfaces/README.wx b/examples/user_interfaces/README.wx index c44eeff2ced1..e39bb388418f 100644 --- a/examples/user_interfaces/README.wx +++ b/examples/user_interfaces/README.wx @@ -16,6 +16,6 @@ matplotlib in a wxPython application http://agni.phys.iit.edu/~kmcivor/wxmpl/ -Each of these approachs has different benefits and drawbacks, so I +Each of these approaches has different benefits and drawbacks, so I encourage you to evaluate each of them and select the one that best meets your needs. diff --git a/examples/user_interfaces/embedding_in_tk_canvas.py b/examples/user_interfaces/embedding_in_tk_canvas.py index 8e069bc6d930..d36987694448 100755 --- a/examples/user_interfaces/embedding_in_tk_canvas.py +++ b/examples/user_interfaces/embedding_in_tk_canvas.py @@ -27,7 +27,7 @@ def draw_figure(canvas, figure, loc=(0, 0)): # Position: convert from top-left anchor to center anchor canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) - # Unfortunatly, there's no accessor for the pointer to the native renderer + # Unfortunately, there's no accessor for the pointer to the native renderer tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) # Return a handle which contains a reference to the photo object diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index 5e854cf44a02..4238e5efa0fe 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -1,6 +1,6 @@ """ Demonstrate how to create an interactive histogram, in which bars -are hidden or shown by cliking on legend markers. +are hidden or shown by clicking on legend markers. The interactivity is encoded in ecmascript (javascript) and inserted in the SVG code in a post-processing step. To render the image, open it in @@ -15,14 +15,14 @@ While flexible, ids are cumbersome to use for large collection of objects. Two mechanisms could be used to simplify things: * systematic grouping of objects into SVG tags, - * assingning classes to each SVG object according to its origin. + * assigning classes to each SVG object according to its origin. For example, instead of modifying the properties of each individual bar, the bars from the `hist` function could either be grouped in a PatchCollection, or be assigned a class="hist_##" attribute. CSS could also be used more extensively to replace repetitive markup -troughout the generated SVG. +throughout the generated SVG. Author: david.huard@gmail.com @@ -114,7 +114,7 @@ oid : str Object identifier. attribute : str - Name of syle attribute. + Name of style attribute. values : [on state, off state] The two values that are switched between. */ diff --git a/examples/user_interfaces/svg_tooltip.py b/examples/user_interfaces/svg_tooltip.py index 2f136156f816..f61a80844672 100644 --- a/examples/user_interfaces/svg_tooltip.py +++ b/examples/user_interfaces/svg_tooltip.py @@ -12,7 +12,7 @@ front. The alternative approach would be to put the tooltip content in `title` -atttributes of SVG objects. Then, using an existing js/CSS library, it +attributes of SVG objects. Then, using an existing js/CSS library, it would be relatively straightforward to create the tooltip in the browser. The content would be dictated by the `title` attribute, and the appearance by the CSS. diff --git a/examples/widgets/README.txt b/examples/widgets/README.txt index 077c373df60e..dc09702e79d1 100644 --- a/examples/widgets/README.txt +++ b/examples/widgets/README.txt @@ -1,2 +1,2 @@ -Examples of how to write primitive, but GUI agnoistic, widgets in +Examples of how to write primitive, but GUI agnostic, widgets in matplotlib diff --git a/examples/widgets/rectangle_selector.py b/examples/widgets/rectangle_selector.py index eaedc686ea31..e80ffa6f8852 100644 --- a/examples/widgets/rectangle_selector.py +++ b/examples/widgets/rectangle_selector.py @@ -4,7 +4,7 @@ the button. This class gives click- and release-events and also draws a line or a box from the click-point to the actual mouseposition (within the same axes) until the button is released. Within the -method 'self.ignore()' it is checked wether the button from eventpress +method 'self.ignore()' it is checked whether the button from eventpress and eventrelease are the same. """ @@ -31,7 +31,7 @@ def toggle_selector(event): toggle_selector.RS.set_active(True) -fig, current_ax = plt.subplots() # make a new plotingrange +fig, current_ax = plt.subplots() # make a new plotting range N = 100000 # If N is large one can see x = np.linspace(0.0, 10.0, N) # improvement by use blitting! From 94f47da5168ce9ec525536c0baf31054438da540 Mon Sep 17 00:00:00 2001 From: Salil Vanvari Date: Wed, 30 Nov 2016 09:35:28 -0800 Subject: [PATCH 11/11] MAINT removing stock_demo.py and data_helper.py. --- examples/pylab_examples/README | 11 ----- examples/pylab_examples/data_helper.py | 60 -------------------------- examples/pylab_examples/stock_demo.py | 19 -------- examples/tests/backend_driver.py | 1 - 4 files changed, 91 deletions(-) delete mode 100755 examples/pylab_examples/data_helper.py delete mode 100644 examples/pylab_examples/stock_demo.py diff --git a/examples/pylab_examples/README b/examples/pylab_examples/README index ca0d48e04541..1fbe320f0cc2 100644 --- a/examples/pylab_examples/README +++ b/examples/pylab_examples/README @@ -1,9 +1,6 @@ Here are some demos of how to use the matplotlib. --- data_helper.py - a convenience module to load some data from the - data dir - -- embedding_in_gtk - The Figure class derives from gtk.DrawingArea, so it is easy to embed in larger applications. @@ -14,11 +11,3 @@ Here are some demos of how to use the matplotlib. -- subplot_demo.py - how to do multiple axes on a single plot -- vline_hline_demo.py - working with straight lines - --- stock_demo.py - working with large datasets. Click on the plot and - launch the navigation tool; wheel mouse over the navigation - buttons to scroll and zoom. There are 58 days of minute by - minute stock quotes for two tickers. The plot lib uses - Numeric's super speedy searchsorted routine to extract the - clipping indices so only the data in the viewport are handled. - diff --git a/examples/pylab_examples/data_helper.py b/examples/pylab_examples/data_helper.py deleted file mode 100755 index f10b804b9745..000000000000 --- a/examples/pylab_examples/data_helper.py +++ /dev/null @@ -1,60 +0,0 @@ -# Some functions to load a return data for the plot demos - -from numpy import fromstring, argsort, take, array, resize -import matplotlib.cbook as cbook - - -def get_two_stock_data(): - """ - load stock time and price data for two stocks The return values - (d1,p1,d2,p2) are the trade time (in days) and prices for stocks 1 - and 2 (intc and aapl) - """ - ticker1, ticker2 = 'INTC', 'AAPL' - - file1 = cbook.get_sample_data('INTC.dat.gz') - file2 = cbook.get_sample_data('AAPL.dat.gz') - M1 = fromstring(file1.read(), '