120120data ['b' ]= data ['a' ]+ 10 * np .random .randn (50 )
121121data ['d' ]= np .abs (data ['d' ])* 100
122122
123- fig ,ax = plt .subplots (figsize = (5 ,2.7 ),constrained_layout = True )
123+ fig ,ax = plt .subplots (figsize = (5 ,2.7 ),layout = 'constrained' )
124124ax .scatter ('a' ,'b' ,c = 'c' ,s = 'd' ,data = data )
125125ax .set_xlabel ('entry a' )
126126ax .set_ylabel ('entry b' );
147147
148148# Note that even in the explicit style, we use `.pyplot.figure` to create the
149149# Figure.
150- fig ,ax = plt .subplots (figsize = (5 ,2.7 ),constrained_layout = True )
150+ fig ,ax = plt .subplots (figsize = (5 ,2.7 ),layout = 'constrained' )
151151ax .plot (x ,x ,label = 'linear' )# Plot some data on the axes.
152152ax .plot (x ,x ** 2 ,label = 'quadratic' )# Plot more data on the axes...
153153ax .plot (x ,x ** 3 ,label = 'cubic' )# ... and some more.
161161
162162x = np .linspace (0 ,2 ,100 )# Sample data.
163163
164- plt .figure (figsize = (5 ,2.7 ),constrained_layout = True )
164+ plt .figure (figsize = (5 ,2.7 ),layout = 'constrained' )
165165plt .plot (x ,x ,label = 'linear' )# Plot some data on the (implicit) axes.
166166plt .plot (x ,x ** 2 ,label = 'quadratic' )# etc.
167167plt .plot (x ,x ** 3 ,label = 'cubic' )
@@ -284,7 +284,7 @@ def my_plotter(ax, data1, data2, param_dict):
284284
285285mu ,sigma = 115 ,15
286286x = 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' )
288288# the histogram of the data
289289n ,bins ,patches = ax .hist (x ,50 ,density = 1 ,facecolor = 'C0' ,alpha = 0.75 )
290290
@@ -380,7 +380,7 @@ def my_plotter(ax, data1, data2, param_dict):
380380# :doc:`/gallery/scales/scales` for other examples). Here we set the scale
381381# manually:
382382
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' )
384384xdata = np .arange (len (data1 ))# make an ordinal for this
385385data = 10 ** data1
386386axs [0 ].plot (xdata ,data )
@@ -401,7 +401,7 @@ def my_plotter(ax, data1, data2, param_dict):
401401# Axis objects to put tick marks. A simple interface to this is
402402# `~.Axes.set_xticks`:
403403
404- fig ,axs = plt .subplots (2 ,1 ,constrained_layout = True )
404+ fig ,axs = plt .subplots (2 ,1 ,layout = 'constrained' )
405405axs [0 ].plot (xdata ,data1 )
406406axs [0 ].set_title ('Automatic ticks' )
407407
@@ -424,7 +424,7 @@ def my_plotter(ax, data1, data2, param_dict):
424424# well as floating point numbers. These get special locators and formatters
425425# as appropriate. For dates:
426426
427- fig ,ax = plt .subplots (figsize = (5 ,2.7 ),constrained_layout = True )
427+ fig ,ax = plt .subplots (figsize = (5 ,2.7 ),layout = 'constrained' )
428428dates = np .arange (np .datetime64 ('2021-11-15' ),np .datetime64 ('2021-12-25' ),
429429np .timedelta64 (1 ,'h' ))
430430data = np .cumsum (np .random .randn (len (dates )))
@@ -439,7 +439,7 @@ def my_plotter(ax, data1, data2, param_dict):
439439# For strings, we get categorical plotting (see:
440440# :doc:`/gallery/lines_bars_and_markers/categorical_variables`).
441441
442- fig ,ax = plt .subplots (figsize = (5 ,2.7 ),constrained_layout = True )
442+ fig ,ax = plt .subplots (figsize = (5 ,2.7 ),layout = 'constrained' )
443443categories = ['turnips' ,'rutabaga' ,'cucumber' ,'pumpkins' ]
444444
445445ax .bar (categories ,np .random .rand (len (categories )));
@@ -464,7 +464,7 @@ def my_plotter(ax, data1, data2, param_dict):
464464# represent the data in different scales or units.
465465
466466
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' )
468468l1 ,= ax1 .plot (t ,s )
469469ax2 = ax1 .twinx ()
470470l2 ,= ax2 .plot (t ,range (len (t )),'C1' )
@@ -485,7 +485,7 @@ def my_plotter(ax, data1, data2, param_dict):
485485X ,Y = np .meshgrid (np .linspace (- 3 ,3 ,128 ),np .linspace (- 3 ,3 ,128 ))
486486Z = (1 - X / 2 + X ** 5 + Y ** 3 )* np .exp (- X ** 2 - Y ** 2 )
487487
488- fig ,axs = plt .subplots (2 ,2 ,constrained_layout = True )
488+ fig ,axs = plt .subplots (2 ,2 ,layout = 'constrained' )
489489pc = axs [0 ,0 ].pcolormesh (X ,Y ,Z ,vmin = - 1 ,vmax = 1 ,cmap = 'RdBu_r' )
490490fig .colorbar (pc ,ax = axs [0 ,0 ])
491491axs [0 ,0 ].set_title ('pcolormesh()' )
@@ -551,7 +551,7 @@ def my_plotter(ax, data1, data2, param_dict):
551551# with Axes objects spanning columns or rows, using `~.pyplot.subplot_mosaic`.
552552
553553fig ,axd = plt .subplot_mosaic ([['upleft' ,'right' ],
554- ['lowleft' ,'right' ]],constrained_layout = True )
554+ ['lowleft' ,'right' ]],layout = 'constrained' )
555555axd ['upleft' ].set_title ('upleft' )
556556axd ['lowleft' ].set_title ('lowleft' )
557557axd ['right' ].set_title ('right' );