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' ),
429429 np .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 )));
@@ -466,7 +466,7 @@ def my_plotter(ax, data1, data2, param_dict):
466466# :doc:`/gallery/subplots_axes_and_figures/secondary_axis` for further
467467# examples.
468468
469- fig , (ax1 , ax3 ) = plt .subplots (1 , 2 , figsize = (8 , 2.7 ), constrained_layout = True )
469+ fig , (ax1 , ax3 ) = plt .subplots (1 , 2 , figsize = (8 , 2.7 ), layout = 'constrained' )
470470l1 , = ax1 .plot (t , s )
471471ax2 = ax1 .twinx ()
472472l2 , = ax2 .plot (t , range (len (t )), 'C1' )
@@ -487,7 +487,7 @@ def my_plotter(ax, data1, data2, param_dict):
487487X , Y = np .meshgrid (np .linspace (- 3 , 3 , 128 ), np .linspace (- 3 , 3 , 128 ))
488488Z = (1 - X / 2 + X ** 5 + Y ** 3 ) * np .exp (- X ** 2 - Y ** 2 )
489489
490- fig , axs = plt .subplots (2 , 2 , constrained_layout = True )
490+ fig , axs = plt .subplots (2 , 2 , layout = 'constrained' )
491491pc = axs [0 , 0 ].pcolormesh (X , Y , Z , vmin = - 1 , vmax = 1 , cmap = 'RdBu_r' )
492492fig .colorbar (pc , ax = axs [0 , 0 ])
493493axs [0 , 0 ].set_title ('pcolormesh()' )
@@ -553,7 +553,7 @@ def my_plotter(ax, data1, data2, param_dict):
553553# with Axes objects spanning columns or rows, using `~.pyplot.subplot_mosaic`.
554554
555555fig , axd = plt .subplot_mosaic ([['upleft' , 'right' ],
556- ['lowleft' , 'right' ]], constrained_layout = True )
556+ ['lowleft' , 'right' ]], layout = 'constrained' )
557557axd ['upleft' ].set_title ('upleft' )
558558axd ['lowleft' ].set_title ('lowleft' )
559559axd ['right' ].set_title ('right' );
0 commit comments