2828# `.Axes.plot` to draw some data on the Axes:
2929
3030fig , ax = plt .subplots () # Create a figure containing a single axes.
31- ax .plot ([1 , 2 , 3 , 4 ], [1 , 4 , 2 , 3 ]); # Plot some data on the axes.
31+ ax .plot ([1 , 2 , 3 , 4 ], [1 , 4 , 2 , 3 ]) # Plot some data on the axes.
3232
3333###############################################################################
3434# .. _figure_parts:
126126fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
127127ax .scatter ('a' , 'b' , c = 'c' , s = 'd' , data = data )
128128ax .set_xlabel ('entry a' )
129- ax .set_ylabel ('entry b' );
129+ ax .set_ylabel ('entry b' )
130130
131131##############################################################################
132132# .. _coding_styles:
159159ax .set_xlabel ('x label' ) # Add an x-label to the axes.
160160ax .set_ylabel ('y label' ) # Add a y-label to the axes.
161161ax .set_title ("Simple Plot" ) # Add a title to the axes.
162- ax .legend (); # Add a legend.
162+ ax .legend () # Add a legend.
163163
164164###############################################################################
165165# or the pyplot-style:
173173plt .xlabel ('x label' )
174174plt .ylabel ('y label' )
175175plt .title ("Simple Plot" )
176- plt .legend ();
176+ plt .legend ()
177177
178178###############################################################################
179179# (In addition, there is a third approach, for the case when embedding
@@ -213,7 +213,7 @@ def my_plotter(ax, data1, data2, param_dict):
213213data1 , data2 , data3 , data4 = np .random .randn (4 , 100 ) # make 4 random data sets
214214fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (5 , 2.7 ))
215215my_plotter (ax1 , data1 , data2 , {'marker' : 'x' })
216- my_plotter (ax2 , data3 , data4 , {'marker' : 'o' });
216+ my_plotter (ax2 , data3 , data4 , {'marker' : 'o' })
217217
218218###############################################################################
219219# Note that if you want to install these as a python package, or any other
@@ -235,7 +235,7 @@ def my_plotter(ax, data1, data2, param_dict):
235235x = np .arange (len (data1 ))
236236ax .plot (x , np .cumsum (data1 ), color = 'blue' , linewidth = 3 , linestyle = '--' )
237237l , = ax .plot (x , np .cumsum (data2 ), color = 'orange' , linewidth = 2 )
238- l .set_linestyle (':' );
238+ l .set_linestyle (':' )
239239
240240###############################################################################
241241# Colors
@@ -248,7 +248,7 @@ def my_plotter(ax, data1, data2, param_dict):
248248# from the interior:
249249
250250fig , ax = plt .subplots (figsize = (5 , 2.7 ))
251- ax .scatter (data1 , data2 , s = 50 , facecolor = 'C0' , edgecolor = 'k' );
251+ ax .scatter (data1 , data2 , s = 50 , facecolor = 'C0' , edgecolor = 'k' )
252252
253253###############################################################################
254254# Linewidths, linestyles, and markersizes
@@ -272,7 +272,7 @@ def my_plotter(ax, data1, data2, param_dict):
272272ax .plot (data2 , 'd' , label = 'data2' )
273273ax .plot (data3 , 'v' , label = 'data3' )
274274ax .plot (data4 , 's' , label = 'data4' )
275- ax .legend ();
275+ ax .legend ()
276276
277277###############################################################################
278278#
@@ -298,7 +298,7 @@ def my_plotter(ax, data1, data2, param_dict):
298298ax .set_title ('Aardvark lengths\n (not really)' )
299299ax .text (75 , .025 , r'$\mu=115,\ \sigma=15$' )
300300ax .axis ([55 , 175 , 0 , 0.03 ])
301- ax .grid (True );
301+ ax .grid (True )
302302
303303###############################################################################
304304# All of the `~.Axes.text` functions return a `matplotlib.text.Text`
@@ -342,7 +342,7 @@ def my_plotter(ax, data1, data2, param_dict):
342342ax .annotate ('local max' , xy = (2 , 1 ), xytext = (3 , 1.5 ),
343343 arrowprops = dict (facecolor = 'black' , shrink = 0.05 ))
344344
345- ax .set_ylim (- 2 , 2 );
345+ ax .set_ylim (- 2 , 2 )
346346
347347###############################################################################
348348# In this basic example, both *xy* and *xytext* are in data coordinates.
@@ -360,7 +360,7 @@ def my_plotter(ax, data1, data2, param_dict):
360360ax .plot (np .arange (len (data1 )), data1 , label = 'data1' )
361361ax .plot (np .arange (len (data2 )), data2 , label = 'data2' )
362362ax .plot (np .arange (len (data3 )), data3 , 'd' , label = 'data3' )
363- ax .legend ();
363+ ax .legend ()
364364
365365##############################################################################
366366# Legends in Matplotlib are quite flexible in layout, placement, and what
@@ -391,7 +391,7 @@ def my_plotter(ax, data1, data2, param_dict):
391391axs [0 ].plot (xdata , data )
392392
393393axs [1 ].set_yscale ('log' )
394- axs [1 ].plot (xdata , data );
394+ axs [1 ].plot (xdata , data )
395395
396396##############################################################################
397397# The scale sets the mapping from data values to spacing along the Axis. This
@@ -413,7 +413,7 @@ def my_plotter(ax, data1, data2, param_dict):
413413axs [1 ].plot (xdata , data1 )
414414axs [1 ].set_xticks (np .arange (0 , 100 , 30 ), ['zero' , '30' , 'sixty' , '90' ])
415415axs [1 ].set_yticks ([- 1.5 , 0 , 1.5 ]) # note that we don't need to specify labels
416- axs [1 ].set_title ('Manual ticks' );
416+ axs [1 ].set_title ('Manual ticks' )
417417
418418##############################################################################
419419# Different scales can have different locators and formatters; for instance
@@ -435,7 +435,7 @@ def my_plotter(ax, data1, data2, param_dict):
435435data = np .cumsum (np .random .randn (len (dates )))
436436ax .plot (dates , data )
437437cdf = mpl .dates .ConciseDateFormatter (ax .xaxis .get_major_locator ())
438- ax .xaxis .set_major_formatter (cdf );
438+ ax .xaxis .set_major_formatter (cdf )
439439
440440##############################################################################
441441# For more information see the date examples
@@ -447,7 +447,7 @@ def my_plotter(ax, data1, data2, param_dict):
447447fig , ax = plt .subplots (figsize = (5 , 2.7 ), layout = 'constrained' )
448448categories = ['turnips' , 'rutabaga' , 'cucumber' , 'pumpkins' ]
449449
450- ax .bar (categories , np .random .rand (len (categories )));
450+ ax .bar (categories , np .random .rand (len (categories )))
451451
452452##############################################################################
453453# One caveat about categorical plotting is that some methods of parsing
@@ -561,7 +561,7 @@ def my_plotter(ax, data1, data2, param_dict):
561561 ['lowleft' , 'right' ]], layout = 'constrained' )
562562axd ['upleft' ].set_title ('upleft' )
563563axd ['lowleft' ].set_title ('lowleft' )
564- axd ['right' ].set_title ('right' );
564+ axd ['right' ].set_title ('right' )
565565
566566###############################################################################
567567# Matplotlib has quite sophisticated tools for arranging Axes: See
0 commit comments