Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b2a8a04

Browse filesBrowse files
committed
Do not use an explicit fignum plt.figure(1) in simple cases
1 parent b6a3400 commit b2a8a04
Copy full SHA for b2a8a04

File tree

Expand file treeCollapse file tree

16 files changed

+18
-18
lines changed
Filter options
Expand file treeCollapse file tree

16 files changed

+18
-18
lines changed

‎examples/axes_grid1/demo_imagegrid_aspect.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_imagegrid_aspect.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import matplotlib.pyplot as plt
88

99
from mpl_toolkits.axes_grid1 import ImageGrid
10-
fig = plt.figure(1)
10+
fig = plt.figure()
1111

1212
grid1 = ImageGrid(fig, 121, (2, 2), axes_pad=0.1,
1313
aspect=True, share_all=True)

‎examples/axes_grid1/simple_rgb.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_rgb.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_rgb():
3131
return R, G, B
3232

3333

34-
fig = plt.figure(1)
34+
fig = plt.figure()
3535
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
3636

3737
r, g, b = get_rgb()

‎examples/axisartist/demo_axisline_style.py

Copy file name to clipboardExpand all lines: examples/axisartist/demo_axisline_style.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import numpy as np
1212

1313
if 1:
14-
fig = plt.figure(1)
14+
fig = plt.figure()
1515
ax = SubplotZero(fig, 111)
1616
fig.add_subplot(ax)
1717

‎examples/axisartist/demo_parasite_axes.py

Copy file name to clipboardExpand all lines: examples/axisartist/demo_parasite_axes.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import matplotlib.pyplot as plt
2020

2121

22-
fig = plt.figure(1)
22+
fig = plt.figure()
2323

2424
host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8])
2525
par1 = ParasiteAxes(host, sharex=host)

‎examples/axisartist/simple_axisartist1.py

Copy file name to clipboardExpand all lines: examples/axisartist/simple_axisartist1.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import matplotlib.pyplot as plt
88
import mpl_toolkits.axisartist as AA
99

10-
fig = plt.figure(1)
10+
fig = plt.figure()
1111
fig.subplots_adjust(right=0.85)
1212
ax = AA.Subplot(fig, 1, 1, 1)
1313
fig.add_subplot(ax)

‎examples/axisartist/simple_axisline.py

Copy file name to clipboardExpand all lines: examples/axisartist/simple_axisline.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from mpl_toolkits.axisartist.axislines import SubplotZero
1010

1111

12-
fig = plt.figure(1)
12+
fig = plt.figure()
1313
fig.subplots_adjust(right=0.85)
1414
ax = SubplotZero(fig, 1, 1, 1)
1515
fig.add_subplot(ax)

‎examples/lines_bars_and_markers/errorbar_limits_simple.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/errorbar_limits_simple.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
###############################################################################
3131

32-
fig = plt.figure(1)
32+
fig = plt.figure()
3333
x = np.arange(10.0) / 10.0
3434
y = (x + 0.1)**2
3535

‎examples/pyplots/pyplot_scales.py

Copy file name to clipboardExpand all lines: examples/pyplots/pyplot_scales.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
x = np.arange(len(y))
2323

2424
# plot with various axes scales
25-
plt.figure(1)
25+
plt.figure()
2626

2727
# linear
2828
plt.subplot(221)

‎examples/pyplots/pyplot_two_subplots.py

Copy file name to clipboardExpand all lines: examples/pyplots/pyplot_two_subplots.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def f(t):
1414
t1 = np.arange(0.0, 5.0, 0.1)
1515
t2 = np.arange(0.0, 5.0, 0.02)
1616

17-
plt.figure(1)
17+
plt.figure()
1818
plt.subplot(211)
1919
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
2020

‎examples/pyplots/whats_new_99_axes_grid.py

Copy file name to clipboardExpand all lines: examples/pyplots/whats_new_99_axes_grid.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_rgb():
3838
return R, G, B
3939

4040

41-
fig = plt.figure(1)
41+
fig = plt.figure()
4242
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
4343

4444
r, g, b = get_rgb()

‎examples/text_labels_and_annotations/demo_text_path.py

Copy file name to clipboardExpand all lines: examples/text_labels_and_annotations/demo_text_path.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def draw(self, renderer=None):
6060

6161
usetex = plt.rcParams["text.usetex"]
6262

63-
fig = plt.figure(1)
63+
fig = plt.figure()
6464

6565
# EXAMPLE 1
6666

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ def add_axes(self, *args, **kwargs):
11651165
Some simple examples::
11661166
11671167
rect = l, b, w, h
1168-
fig = plt.figure(1)
1168+
fig = plt.figure()
11691169
fig.add_axes(rect,label=label1)
11701170
fig.add_axes(rect,label=label2)
11711171
fig.add_axes(rect, frameon=False, facecolor='g')
@@ -1308,7 +1308,7 @@ def add_subplot(self, *args, **kwargs):
13081308
--------
13091309
::
13101310
1311-
fig=plt.figure(1)
1311+
fig=plt.figure()
13121312
fig.add_subplot(221)
13131313
13141314
# equivalent but more general

‎lib/matplotlib/offsetbox.py

Copy file name to clipboardExpand all lines: lib/matplotlib/offsetbox.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ def update_offset(self, dx, dy):
17521752

17531753
if __name__ == "__main__":
17541754
import matplotlib.pyplot as plt
1755-
fig = plt.figure(1)
1755+
fig = plt.figure()
17561756
fig.clf()
17571757
ax = plt.subplot(121)
17581758

‎tutorials/introductory/pyplot.py

Copy file name to clipboardExpand all lines: tutorials/introductory/pyplot.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def f(t):
253253
t1 = np.arange(0.0, 5.0, 0.1)
254254
t2 = np.arange(0.0, 5.0, 0.02)
255255

256-
plt.figure(1)
256+
plt.figure()
257257
plt.subplot(211)
258258
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
259259

@@ -432,7 +432,7 @@ def f(t):
432432
x = np.arange(len(y))
433433

434434
# plot with various axes scales
435-
plt.figure(1)
435+
plt.figure()
436436

437437
# linear
438438
plt.subplot(221)

‎tutorials/toolkits/axes_grid.py

Copy file name to clipboardExpand all lines: tutorials/toolkits/axes_grid.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
389389
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
390390
391-
fig = plt.figure(1)
391+
fig = plt.figure()
392392
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
393393
394394
r, g, b = get_rgb() # r,g,b are 2-d images

‎tutorials/toolkits/axisartist.py

Copy file name to clipboardExpand all lines: tutorials/toolkits/axisartist.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
To create an axes, ::
5252
5353
import mpl_toolkits.axisartist as AA
54-
fig = plt.figure(1)
54+
fig = plt.figure()
5555
ax = AA.Axes(fig, [0.1, 0.1, 0.8, 0.8])
5656
fig.add_axes(ax)
5757

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.