From b2a8a049fa4801992d257a073b052eba9aedd13c Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 2 Sep 2018 10:47:13 +0200 Subject: [PATCH] Do not use an explicit fignum plt.figure(1) in simple cases --- examples/axes_grid1/demo_imagegrid_aspect.py | 2 +- examples/axes_grid1/simple_rgb.py | 2 +- examples/axisartist/demo_axisline_style.py | 2 +- examples/axisartist/demo_parasite_axes.py | 2 +- examples/axisartist/simple_axisartist1.py | 2 +- examples/axisartist/simple_axisline.py | 2 +- examples/lines_bars_and_markers/errorbar_limits_simple.py | 2 +- examples/pyplots/pyplot_scales.py | 2 +- examples/pyplots/pyplot_two_subplots.py | 2 +- examples/pyplots/whats_new_99_axes_grid.py | 2 +- examples/text_labels_and_annotations/demo_text_path.py | 2 +- lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/offsetbox.py | 2 +- tutorials/introductory/pyplot.py | 4 ++-- tutorials/toolkits/axes_grid.py | 2 +- tutorials/toolkits/axisartist.py | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/axes_grid1/demo_imagegrid_aspect.py b/examples/axes_grid1/demo_imagegrid_aspect.py index 35162fae674a..3369777460a5 100644 --- a/examples/axes_grid1/demo_imagegrid_aspect.py +++ b/examples/axes_grid1/demo_imagegrid_aspect.py @@ -7,7 +7,7 @@ import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import ImageGrid -fig = plt.figure(1) +fig = plt.figure() grid1 = ImageGrid(fig, 121, (2, 2), axes_pad=0.1, aspect=True, share_all=True) diff --git a/examples/axes_grid1/simple_rgb.py b/examples/axes_grid1/simple_rgb.py index 8048c34b4f90..d0d5c576604a 100644 --- a/examples/axes_grid1/simple_rgb.py +++ b/examples/axes_grid1/simple_rgb.py @@ -31,7 +31,7 @@ def get_rgb(): return R, G, B -fig = plt.figure(1) +fig = plt.figure() ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) r, g, b = get_rgb() diff --git a/examples/axisartist/demo_axisline_style.py b/examples/axisartist/demo_axisline_style.py index 7823e9c52b12..0ddabcb15cb9 100644 --- a/examples/axisartist/demo_axisline_style.py +++ b/examples/axisartist/demo_axisline_style.py @@ -11,7 +11,7 @@ import numpy as np if 1: - fig = plt.figure(1) + fig = plt.figure() ax = SubplotZero(fig, 111) fig.add_subplot(ax) diff --git a/examples/axisartist/demo_parasite_axes.py b/examples/axisartist/demo_parasite_axes.py index d7e852f96fe6..61a6f0e009c3 100644 --- a/examples/axisartist/demo_parasite_axes.py +++ b/examples/axisartist/demo_parasite_axes.py @@ -19,7 +19,7 @@ import matplotlib.pyplot as plt -fig = plt.figure(1) +fig = plt.figure() host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8]) par1 = ParasiteAxes(host, sharex=host) diff --git a/examples/axisartist/simple_axisartist1.py b/examples/axisartist/simple_axisartist1.py index 08f1a9f2c9df..ee2b44c5bec2 100644 --- a/examples/axisartist/simple_axisartist1.py +++ b/examples/axisartist/simple_axisartist1.py @@ -7,7 +7,7 @@ import matplotlib.pyplot as plt import mpl_toolkits.axisartist as AA -fig = plt.figure(1) +fig = plt.figure() fig.subplots_adjust(right=0.85) ax = AA.Subplot(fig, 1, 1, 1) fig.add_subplot(ax) diff --git a/examples/axisartist/simple_axisline.py b/examples/axisartist/simple_axisline.py index 9502d6a50a1a..9ec7283894fb 100644 --- a/examples/axisartist/simple_axisline.py +++ b/examples/axisartist/simple_axisline.py @@ -9,7 +9,7 @@ from mpl_toolkits.axisartist.axislines import SubplotZero -fig = plt.figure(1) +fig = plt.figure() fig.subplots_adjust(right=0.85) ax = SubplotZero(fig, 1, 1, 1) fig.add_subplot(ax) diff --git a/examples/lines_bars_and_markers/errorbar_limits_simple.py b/examples/lines_bars_and_markers/errorbar_limits_simple.py index 68f2d90d4be4..dd2a37423d70 100644 --- a/examples/lines_bars_and_markers/errorbar_limits_simple.py +++ b/examples/lines_bars_and_markers/errorbar_limits_simple.py @@ -29,7 +29,7 @@ ############################################################################### -fig = plt.figure(1) +fig = plt.figure() x = np.arange(10.0) / 10.0 y = (x + 0.1)**2 diff --git a/examples/pyplots/pyplot_scales.py b/examples/pyplots/pyplot_scales.py index a45647b88dda..77536f350c8f 100644 --- a/examples/pyplots/pyplot_scales.py +++ b/examples/pyplots/pyplot_scales.py @@ -22,7 +22,7 @@ x = np.arange(len(y)) # plot with various axes scales -plt.figure(1) +plt.figure() # linear plt.subplot(221) diff --git a/examples/pyplots/pyplot_two_subplots.py b/examples/pyplots/pyplot_two_subplots.py index 964e1fdfd6e7..4578f096bbb4 100644 --- a/examples/pyplots/pyplot_two_subplots.py +++ b/examples/pyplots/pyplot_two_subplots.py @@ -14,7 +14,7 @@ def f(t): t1 = np.arange(0.0, 5.0, 0.1) t2 = np.arange(0.0, 5.0, 0.02) -plt.figure(1) +plt.figure() plt.subplot(211) plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') diff --git a/examples/pyplots/whats_new_99_axes_grid.py b/examples/pyplots/whats_new_99_axes_grid.py index c77f23f1213f..7a9666f8e9e3 100644 --- a/examples/pyplots/whats_new_99_axes_grid.py +++ b/examples/pyplots/whats_new_99_axes_grid.py @@ -38,7 +38,7 @@ def get_rgb(): return R, G, B -fig = plt.figure(1) +fig = plt.figure() ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) r, g, b = get_rgb() diff --git a/examples/text_labels_and_annotations/demo_text_path.py b/examples/text_labels_and_annotations/demo_text_path.py index d1e2d421b07c..69dc32386c9b 100644 --- a/examples/text_labels_and_annotations/demo_text_path.py +++ b/examples/text_labels_and_annotations/demo_text_path.py @@ -60,7 +60,7 @@ def draw(self, renderer=None): usetex = plt.rcParams["text.usetex"] - fig = plt.figure(1) + fig = plt.figure() # EXAMPLE 1 diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 5ccefc2904e5..5c47c6f6b060 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1165,7 +1165,7 @@ def add_axes(self, *args, **kwargs): Some simple examples:: rect = l, b, w, h - fig = plt.figure(1) + fig = plt.figure() fig.add_axes(rect,label=label1) fig.add_axes(rect,label=label2) fig.add_axes(rect, frameon=False, facecolor='g') @@ -1308,7 +1308,7 @@ def add_subplot(self, *args, **kwargs): -------- :: - fig=plt.figure(1) + fig=plt.figure() fig.add_subplot(221) # equivalent but more general diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 75d910936555..b2a86e744cca 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -1752,7 +1752,7 @@ def update_offset(self, dx, dy): if __name__ == "__main__": import matplotlib.pyplot as plt - fig = plt.figure(1) + fig = plt.figure() fig.clf() ax = plt.subplot(121) diff --git a/tutorials/introductory/pyplot.py b/tutorials/introductory/pyplot.py index 124a57f51c90..a36f5108e56f 100644 --- a/tutorials/introductory/pyplot.py +++ b/tutorials/introductory/pyplot.py @@ -253,7 +253,7 @@ def f(t): t1 = np.arange(0.0, 5.0, 0.1) t2 = np.arange(0.0, 5.0, 0.02) -plt.figure(1) +plt.figure() plt.subplot(211) plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') @@ -432,7 +432,7 @@ def f(t): x = np.arange(len(y)) # plot with various axes scales -plt.figure(1) +plt.figure() # linear plt.subplot(221) diff --git a/tutorials/toolkits/axes_grid.py b/tutorials/toolkits/axes_grid.py index 55645da3efb5..4ff2dd367e8a 100644 --- a/tutorials/toolkits/axes_grid.py +++ b/tutorials/toolkits/axes_grid.py @@ -388,7 +388,7 @@ from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes - fig = plt.figure(1) + fig = plt.figure() ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) r, g, b = get_rgb() # r,g,b are 2-d images diff --git a/tutorials/toolkits/axisartist.py b/tutorials/toolkits/axisartist.py index 9465ab02551a..8c5295dedebd 100644 --- a/tutorials/toolkits/axisartist.py +++ b/tutorials/toolkits/axisartist.py @@ -51,7 +51,7 @@ To create an axes, :: import mpl_toolkits.axisartist as AA - fig = plt.figure(1) + fig = plt.figure() ax = AA.Axes(fig, [0.1, 0.1, 0.8, 0.8]) fig.add_axes(ax)