120
120
data ['b' ] = data ['a' ] + 10 * np .random .randn (50 )
121
121
data ['d' ] = np .abs (data ['d' ]) * 100
122
122
123
- fig , ax = plt .subplots (figsize = (5 , 2.7 ), constrained_layout = True )
123
+ fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
124
124
ax .scatter ('a' , 'b' , c = 'c' , s = 'd' , data = data )
125
125
ax .set_xlabel ('entry a' )
126
126
ax .set_ylabel ('entry b' );
147
147
148
148
# Note that even in the explicit style, we use `.pyplot.figure` to create the
149
149
# Figure.
150
- fig , ax = plt .subplots (figsize = (5 , 2.7 ), constrained_layout = True )
150
+ fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
151
151
ax .plot (x , x , label = 'linear' ) # Plot some data on the axes.
152
152
ax .plot (x , x ** 2 , label = 'quadratic' ) # Plot more data on the axes...
153
153
ax .plot (x , x ** 3 , label = 'cubic' ) # ... and some more.
161
161
162
162
x = np .linspace (0 , 2 , 100 ) # Sample data.
163
163
164
- plt .figure (figsize = (5 , 2.7 ), constrained_layout = True )
164
+ plt .figure (figsize = (5 , 2.7 ), layout = 'constrained' )
165
165
plt .plot (x , x , label = 'linear' ) # Plot some data on the (implicit) axes.
166
166
plt .plot (x , x ** 2 , label = 'quadratic' ) # etc.
167
167
plt .plot (x , x ** 3 , label = 'cubic' )
@@ -284,7 +284,7 @@ def my_plotter(ax, data1, data2, param_dict):
284
284
285
285
mu , sigma = 115 , 15
286
286
x = mu + sigma * np .random .randn (10000 )
287
- fig , ax = plt .subplots (figsize = (5 , 2.7 ), constrained_layout = True )
287
+ fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
288
288
# the histogram of the data
289
289
n , bins , patches = ax .hist (x , 50 , density = 1 , facecolor = 'C0' , alpha = 0.75 )
290
290
@@ -380,7 +380,7 @@ def my_plotter(ax, data1, data2, param_dict):
380
380
# :doc:`/gallery/scales/scales` for other examples). Here we set the scale
381
381
# manually:
382
382
383
- fig , axs = plt .subplots (1 , 2 , figsize = (5 , 2.7 ), constrained_layout = True )
383
+ fig , axs = plt .subplots (1 , 2 , figsize = (5 , 2.7 ), layout = 'constrained' )
384
384
xdata = np .arange (len (data1 )) # make an ordinal for this
385
385
data = 10 ** data1
386
386
axs [0 ].plot (xdata , data )
@@ -401,7 +401,7 @@ def my_plotter(ax, data1, data2, param_dict):
401
401
# Axis objects to put tick marks. A simple interface to this is
402
402
# `~.Axes.set_xticks`:
403
403
404
- fig , axs = plt .subplots (2 , 1 , constrained_layout = True )
404
+ fig , axs = plt .subplots (2 , 1 , layout = 'constrained' )
405
405
axs [0 ].plot (xdata , data1 )
406
406
axs [0 ].set_title ('Automatic ticks' )
407
407
@@ -424,7 +424,7 @@ def my_plotter(ax, data1, data2, param_dict):
424
424
# well as floating point numbers. These get special locators and formatters
425
425
# as appropriate. For dates:
426
426
427
- fig , ax = plt .subplots (figsize = (5 , 2.7 ), constrained_layout = True )
427
+ fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
428
428
dates = np .arange (np .datetime64 ('2021-11-15' ), np .datetime64 ('2021-12-25' ),
429
429
np .timedelta64 (1 , 'h' ))
430
430
data = np .cumsum (np .random .randn (len (dates )))
@@ -439,7 +439,7 @@ def my_plotter(ax, data1, data2, param_dict):
439
439
# For strings, we get categorical plotting (see:
440
440
# :doc:`/gallery/lines_bars_and_markers/categorical_variables`).
441
441
442
- fig , ax = plt .subplots (figsize = (5 , 2.7 ), constrained_layout = True )
442
+ fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
443
443
categories = ['turnips' , 'rutabaga' , 'cucumber' , 'pumpkins' ]
444
444
445
445
ax .bar (categories , np .random .rand (len (categories )));
@@ -464,7 +464,7 @@ def my_plotter(ax, data1, data2, param_dict):
464
464
# represent the data in different scales or units.
465
465
466
466
467
- fig , (ax1 , ax3 ) = plt .subplots (1 , 2 , figsize = (8 , 2.7 ), constrained_layout = True )
467
+ fig , (ax1 , ax3 ) = plt .subplots (1 , 2 , figsize = (8 , 2.7 ), layout = 'constrained' )
468
468
l1 , = ax1 .plot (t , s )
469
469
ax2 = ax1 .twinx ()
470
470
l2 , = ax2 .plot (t , range (len (t )), 'C1' )
@@ -485,7 +485,7 @@ def my_plotter(ax, data1, data2, param_dict):
485
485
X , Y = np .meshgrid (np .linspace (- 3 , 3 , 128 ), np .linspace (- 3 , 3 , 128 ))
486
486
Z = (1 - X / 2 + X ** 5 + Y ** 3 ) * np .exp (- X ** 2 - Y ** 2 )
487
487
488
- fig , axs = plt .subplots (2 , 2 , constrained_layout = True )
488
+ fig , axs = plt .subplots (2 , 2 , layout = 'constrained' )
489
489
pc = axs [0 , 0 ].pcolormesh (X , Y , Z , vmin = - 1 , vmax = 1 , cmap = 'RdBu_r' )
490
490
fig .colorbar (pc , ax = axs [0 , 0 ])
491
491
axs [0 , 0 ].set_title ('pcolormesh()' )
@@ -551,7 +551,7 @@ def my_plotter(ax, data1, data2, param_dict):
551
551
# with Axes objects spanning columns or rows, using `~.pyplot.subplot_mosaic`.
552
552
553
553
fig , axd = plt .subplot_mosaic ([['upleft' , 'right' ],
554
- ['lowleft' , 'right' ]], constrained_layout = True )
554
+ ['lowleft' , 'right' ]], layout = 'constrained' )
555
555
axd ['upleft' ].set_title ('upleft' )
556
556
axd ['lowleft' ].set_title ('lowleft' )
557
557
axd ['right' ].set_title ('right' );
0 commit comments