diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d31739ce997..e471b8d8be53 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,8 @@ mpl-run: &mpl-install doc-run: &doc-build name: Build documentation command: | + # Set epoch to date of latest tag. + export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))" make html O=-T rm -r build/html/_sources working_directory: doc diff --git a/examples/axes_grid1/demo_anchored_direction_arrows.py b/examples/axes_grid1/demo_anchored_direction_arrows.py index d9b1eb2cc584..4c353ff85f17 100644 --- a/examples/axes_grid1/demo_anchored_direction_arrows.py +++ b/examples/axes_grid1/demo_anchored_direction_arrows.py @@ -9,6 +9,10 @@ from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows import matplotlib.font_manager as fm + +# Fixing random state for reproducibility +np.random.seed(19680801) + fig, ax = plt.subplots() ax.imshow(np.random.random((10, 10))) diff --git a/examples/event_handling/image_slices_viewer.py b/examples/event_handling/image_slices_viewer.py index bbc8af43e011..96cf8f64a3a0 100644 --- a/examples/event_handling/image_slices_viewer.py +++ b/examples/event_handling/image_slices_viewer.py @@ -10,6 +10,10 @@ import matplotlib.pyplot as plt +# Fixing random state for reproducibility +np.random.seed(19680801) + + class IndexTracker: def __init__(self, ax, X): self.ax = ax diff --git a/examples/event_handling/pick_event_demo.py b/examples/event_handling/pick_event_demo.py index f2cd07a01954..84c635c27ca8 100644 --- a/examples/event_handling/pick_event_demo.py +++ b/examples/event_handling/pick_event_demo.py @@ -70,6 +70,10 @@ def pick_handler(event): from numpy.random import rand +# Fixing random state for reproducibility +np.random.seed(19680801) + + def pick_simple(): # simple picking, lines, rectangles and text fig, (ax1, ax2) = plt.subplots(2, 1) diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 5712c88588aa..162fbdf65ade 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -11,6 +11,9 @@ import matplotlib.pyplot as plt +# Fixing random state for reproducibility +np.random.seed(19680801) + X = np.random.rand(100, 1000) xs = np.mean(X, axis=1) ys = np.std(X, axis=1) diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index 9a08faea8521..9afe60ce935c 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -17,6 +17,10 @@ import matplotlib.pyplot as plt import numpy as np + +# Fixing random state for reproducibility +np.random.seed(19680801) + figsrc, axsrc = plt.subplots() figzoom, axzoom = plt.subplots() axsrc.set(xlim=(0, 1), ylim=(0, 1), autoscale_on=False, diff --git a/examples/images_contours_and_fields/image_demo.py b/examples/images_contours_and_fields/image_demo.py index 2eea6ca18d2a..452f1d50dbcf 100644 --- a/examples/images_contours_and_fields/image_demo.py +++ b/examples/images_contours_and_fields/image_demo.py @@ -17,6 +17,10 @@ from matplotlib.path import Path from matplotlib.patches import PathPatch + +# Fixing random state for reproducibility +np.random.seed(19680801) + ############################################################################### # First we'll generate a simple bivariate normal distribution. diff --git a/examples/images_contours_and_fields/pcolor_demo.py b/examples/images_contours_and_fields/pcolor_demo.py index efaedc402f76..bc9c8f6c5247 100644 --- a/examples/images_contours_and_fields/pcolor_demo.py +++ b/examples/images_contours_and_fields/pcolor_demo.py @@ -12,6 +12,10 @@ import numpy as np from matplotlib.colors import LogNorm + +# Fixing random state for reproducibility +np.random.seed(19680801) + ############################################################################### # A simple pcolor demo # -------------------- diff --git a/examples/images_contours_and_fields/spy_demos.py b/examples/images_contours_and_fields/spy_demos.py index a24f134e407c..af70f48cd4c8 100644 --- a/examples/images_contours_and_fields/spy_demos.py +++ b/examples/images_contours_and_fields/spy_demos.py @@ -9,6 +9,10 @@ import matplotlib.pyplot as plt import numpy as np + +# Fixing random state for reproducibility +np.random.seed(19680801) + fig, axs = plt.subplots(2, 2) ax1 = axs[0, 0] ax2 = axs[0, 1] diff --git a/examples/lines_bars_and_markers/scatter_custom_symbol.py b/examples/lines_bars_and_markers/scatter_custom_symbol.py index a66410c31caf..428a68318671 100644 --- a/examples/lines_bars_and_markers/scatter_custom_symbol.py +++ b/examples/lines_bars_and_markers/scatter_custom_symbol.py @@ -9,6 +9,10 @@ import matplotlib.pyplot as plt import numpy as np + +# Fixing random state for reproducibility +np.random.seed(19680801) + # unit area ellipse rx, ry = 3., 1. area = rx * ry * np.pi diff --git a/examples/lines_bars_and_markers/stackplot_demo.py b/examples/lines_bars_and_markers/stackplot_demo.py index 27db8ebd5a8a..8df6d4f4cc8d 100644 --- a/examples/lines_bars_and_markers/stackplot_demo.py +++ b/examples/lines_bars_and_markers/stackplot_demo.py @@ -12,6 +12,10 @@ import numpy as np import matplotlib.pyplot as plt + +# Fixing random state for reproducibility +np.random.seed(19680801) + x = [1, 2, 3, 4, 5] y1 = [1, 1, 2, 3, 5] y2 = [0, 4, 2, 6, 8] diff --git a/examples/lines_bars_and_markers/vline_hline_demo.py b/examples/lines_bars_and_markers/vline_hline_demo.py index 458bb27327f9..95616600573e 100644 --- a/examples/lines_bars_and_markers/vline_hline_demo.py +++ b/examples/lines_bars_and_markers/vline_hline_demo.py @@ -10,6 +10,9 @@ import numpy as np +# Fixing random state for reproducibility +np.random.seed(19680801) + t = np.arange(0.0, 5.0, 0.1) s = np.exp(-t) + np.sin(2 * np.pi * t) + 1 nse = np.random.normal(0.0, 0.3, t.shape) * s diff --git a/examples/recipes/create_subplots.py b/examples/recipes/create_subplots.py index ec3720e1fb3c..3c641a8f9d56 100644 --- a/examples/recipes/create_subplots.py +++ b/examples/recipes/create_subplots.py @@ -11,6 +11,10 @@ import matplotlib.pyplot as plt import numpy as np + +# Fixing random state for reproducibility +np.random.seed(19680801) + x = np.random.randn(50) # old style diff --git a/examples/recipes/fill_between_alpha.py b/examples/recipes/fill_between_alpha.py index f97f3730731c..6e40adf3338e 100644 --- a/examples/recipes/fill_between_alpha.py +++ b/examples/recipes/fill_between_alpha.py @@ -16,6 +16,10 @@ import numpy as np import matplotlib.cbook as cbook + +# Fixing random state for reproducibility +np.random.seed(19680801) + # load up some sample financial data with cbook.get_sample_data('goog.npz') as datafile: r = np.load(datafile)['price_data'].view(np.recarray) diff --git a/examples/scales/power_norm.py b/examples/scales/power_norm.py index 60ef2551875a..60795fb5b524 100644 --- a/examples/scales/power_norm.py +++ b/examples/scales/power_norm.py @@ -12,9 +12,13 @@ import numpy as np from numpy.random import multivariate_normal + +# Fixing random state for reproducibility. +np.random.seed(19680801) + data = np.vstack([ multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000), - multivariate_normal([30, 20], [[2, 3], [1, 3]], size=1000) + multivariate_normal([30, 20], [[3, 1], [1, 3]], size=1000) ]) gammas = [0.8, 0.5, 0.3] diff --git a/examples/scales/scales.py b/examples/scales/scales.py index 0716d90c7414..d47d0281b33c 100644 --- a/examples/scales/scales.py +++ b/examples/scales/scales.py @@ -87,7 +87,7 @@ def inverse(a): ax = axs[2, 1] -t = np.arange(-170.0, 170.0, 0.1) +t = np.arange(0, 170.0, 0.1) s = t / 2. ax.plot(t, s, '-', lw=2) @@ -95,9 +95,9 @@ def inverse(a): ax.set_yscale('function', functions=(forward, inverse)) ax.set_title('function: Mercator') ax.grid(True) -ax.set_xlim([-180, 180]) +ax.set_xlim([0, 180]) ax.yaxis.set_minor_formatter(NullFormatter()) -ax.yaxis.set_major_locator(FixedLocator(np.arange(-90, 90, 30))) +ax.yaxis.set_major_locator(FixedLocator(np.arange(0, 90, 10))) plt.show() diff --git a/examples/shapes_and_collections/ellipse_demo.py b/examples/shapes_and_collections/ellipse_demo.py index 8d143b8865e2..e5e9c6405a6f 100644 --- a/examples/shapes_and_collections/ellipse_demo.py +++ b/examples/shapes_and_collections/ellipse_demo.py @@ -11,6 +11,10 @@ import numpy as np from matplotlib.patches import Ellipse + +# Fixing random state for reproducibility +np.random.seed(19680801) + NUM = 250 ells = [Ellipse(xy=np.random.rand(2) * 10, diff --git a/examples/style_sheets/bmh.py b/examples/style_sheets/bmh.py index 6d87583da7ff..c0379b188c2a 100644 --- a/examples/style_sheets/bmh.py +++ b/examples/style_sheets/bmh.py @@ -9,16 +9,19 @@ .. [1] http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/ """ -from numpy.random import beta +import numpy as np import matplotlib.pyplot as plt +# Fixing random state for reproducibility +np.random.seed(19680801) + plt.style.use('bmh') def plot_beta_hist(ax, a, b): - ax.hist(beta(a, b, size=10000), histtype="stepfilled", - bins=25, alpha=0.8, density=True) + ax.hist(np.random.beta(a, b, size=10000), + histtype="stepfilled", bins=25, alpha=0.8, density=True) fig, ax = plt.subplots() diff --git a/examples/style_sheets/plot_solarizedlight2.py b/examples/style_sheets/plot_solarizedlight2.py index c874a889a137..0051a5cf69dc 100644 --- a/examples/style_sheets/plot_solarizedlight2.py +++ b/examples/style_sheets/plot_solarizedlight2.py @@ -23,6 +23,11 @@ """ import matplotlib.pyplot as plt import numpy as np + + +# Fixing random state for reproducibility +np.random.seed(19680801) + x = np.linspace(0, 10) with plt.style.context('Solarize_Light2'): plt.plot(x, np.sin(x) + x + np.random.randn(50)) diff --git a/examples/subplots_axes_and_figures/axes_box_aspect.py b/examples/subplots_axes_and_figures/axes_box_aspect.py index 30c078d25b11..aacac960c23e 100644 --- a/examples/subplots_axes_and_figures/axes_box_aspect.py +++ b/examples/subplots_axes_and_figures/axes_box_aspect.py @@ -80,6 +80,7 @@ fig4, (ax, ax2) = plt.subplots(ncols=2, constrained_layout=True) +np.random.seed(19680801) # Fixing random state for reproducibility im = np.random.rand(16, 27) ax.imshow(im) @@ -106,6 +107,7 @@ axs[1, 0].set_box_aspect(1) axs[1, 1].set_box_aspect(3/1) +np.random.seed(19680801) # Fixing random state for reproducibility x, y = np.random.randn(2, 400) * [[.5], [180]] axs[1, 0].scatter(x, y) axs[0, 0].hist(x) diff --git a/examples/subplots_axes_and_figures/colorbar_placement.py b/examples/subplots_axes_and_figures/colorbar_placement.py index eee99acbea0a..3eb4f9aed758 100644 --- a/examples/subplots_axes_and_figures/colorbar_placement.py +++ b/examples/subplots_axes_and_figures/colorbar_placement.py @@ -11,6 +11,10 @@ import matplotlib.pyplot as plt import numpy as np + +# Fixing random state for reproducibility +np.random.seed(19680801) + fig, axs = plt.subplots(2, 2) cm = ['RdBu_r', 'viridis'] for col in range(2): diff --git a/examples/subplots_axes_and_figures/subplot_toolbar.py b/examples/subplots_axes_and_figures/subplot_toolbar.py index bd190c05a9bc..e65b1f7091f0 100644 --- a/examples/subplots_axes_and_figures/subplot_toolbar.py +++ b/examples/subplots_axes_and_figures/subplot_toolbar.py @@ -8,6 +8,10 @@ import matplotlib.pyplot as plt import numpy as np + +# Fixing random state for reproducibility +np.random.seed(19680801) + fig, axs = plt.subplots(2, 2) axs[0, 0].imshow(np.random.random((100, 100))) diff --git a/examples/text_labels_and_annotations/demo_text_rotation_mode.py b/examples/text_labels_and_annotations/demo_text_rotation_mode.py index 2cb7fd66afd4..0e209b604d7a 100644 --- a/examples/text_labels_and_annotations/demo_text_rotation_mode.py +++ b/examples/text_labels_and_annotations/demo_text_rotation_mode.py @@ -64,7 +64,7 @@ def test_rotation_mode(fig, mode, subplot_location): # highlight bbox fig.canvas.draw() for ax, tx in zip(grid, texts): - bb = tx.get_window_extent().inverse_transformed(ax.transData) + bb = tx.get_window_extent().transformed(ax.transData.inverted()) rect = plt.Rectangle((bb.x0, bb.y0), bb.width, bb.height, facecolor="C1", alpha=0.3, zorder=2) ax.add_patch(rect) diff --git a/examples/ticks_and_spines/colorbar_tick_labelling_demo.py b/examples/ticks_and_spines/colorbar_tick_labelling_demo.py index b6a4ba9f898b..1aab0970a3c5 100644 --- a/examples/ticks_and_spines/colorbar_tick_labelling_demo.py +++ b/examples/ticks_and_spines/colorbar_tick_labelling_demo.py @@ -13,6 +13,10 @@ from matplotlib import cm from numpy.random import randn + +# Fixing random state for reproducibility +np.random.seed(19680801) + ############################################################################### # Make plot with vertical (default) colorbar diff --git a/examples/userdemo/annotate_text_arrow.py b/examples/userdemo/annotate_text_arrow.py index 193fe52efbba..afe3164a0213 100644 --- a/examples/userdemo/annotate_text_arrow.py +++ b/examples/userdemo/annotate_text_arrow.py @@ -8,6 +8,10 @@ import numpy as np import matplotlib.pyplot as plt + +# Fixing random state for reproducibility +np.random.seed(19680801) + fig, ax = plt.subplots(figsize=(5, 5)) ax.set_aspect(1) diff --git a/tutorials/colors/colormap-manipulation.py b/tutorials/colors/colormap-manipulation.py index 67e67e68d894..f312b181b017 100644 --- a/tutorials/colors/colormap-manipulation.py +++ b/tutorials/colors/colormap-manipulation.py @@ -37,7 +37,6 @@ from matplotlib.colors import ListedColormap, LinearSegmentedColormap viridis = cm.get_cmap('viridis', 8) -print(viridis) ############################################################################## # The object ``viridis`` is a callable, that when passed a float between @@ -74,7 +73,6 @@ # float array between 0 and 1. copper = cm.get_cmap('copper', 8) -print(copper) print('copper(range(8))', copper(range(8))) print('copper(np.linspace(0, 1, 8))', copper(np.linspace(0, 1, 8)))