2626
2727fig , ax = plt .subplots () # Create a figure containing a single axes.
2828ax .plot ([1 , 2 , 3 , 4 ], [1 , 4 , 2 , 3 ]) # Plot some data on the axes.
29+ plt .show ()
2930
3031###############################################################################
3132# .. _figure_parts:
124125ax .scatter ('a' , 'b' , c = 'c' , s = 'd' , data = data )
125126ax .set_xlabel ('entry a' )
126127ax .set_ylabel ('entry b' )
128+ plt .show ()
127129
128130##############################################################################
129131# .. _coding_styles:
154156ax .set_ylabel ('y label' ) # Add a y-label to the axes.
155157ax .set_title ("Simple Plot" ) # Add a title to the axes.
156158ax .legend () # Add a legend.
159+ plt .show ()
157160
158161###############################################################################
159162# or the pyplot-style:
168171plt .ylabel ('y label' )
169172plt .title ("Simple Plot" )
170173plt .legend ()
174+ plt .show ()
171175
172176###############################################################################
173177# (In addition, there is a third approach, for the case when embedding
@@ -209,6 +213,7 @@ def my_plotter(ax, data1, data2, param_dict):
209213fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (5 , 2.7 ))
210214my_plotter (ax1 , data1 , data2 , {'marker' : 'x' })
211215my_plotter (ax2 , data3 , data4 , {'marker' : 'o' })
216+ plt .show ()
212217
213218###############################################################################
214219# Note that if you want to install these as a python package, or any other
@@ -231,6 +236,7 @@ def my_plotter(ax, data1, data2, param_dict):
231236ax .plot (x , np .cumsum (data1 ), color = 'blue' , linewidth = 3 , linestyle = '--' )
232237l , = ax .plot (x , np .cumsum (data2 ), color = 'orange' , linewidth = 2 )
233238l .set_linestyle (':' )
239+ plt .show ()
234240
235241###############################################################################
236242# Colors
@@ -245,6 +251,7 @@ def my_plotter(ax, data1, data2, param_dict):
245251fig , ax = plt .subplots (figsize = (5 , 2.7 ))
246252x = np .arange (len (data1 ))
247253ax .scatter (data1 , data2 , s = 50 , facecolor = 'C0' , edgecolor = 'k' )
254+ plt .show ()
248255
249256###############################################################################
250257# Linewidths, linestyles, and markersizes
@@ -269,6 +276,7 @@ def my_plotter(ax, data1, data2, param_dict):
269276ax .plot (data3 , 'v' , label = 'data3' )
270277ax .plot (data4 , 's' , label = 'data4' )
271278ax .legend ()
279+ plt .show ()
272280
273281################################################################################
274282#
@@ -340,6 +348,7 @@ def my_plotter(ax, data1, data2, param_dict):
340348 arrowprops = dict (facecolor = 'black' , shrink = 0.05 ))
341349
342350ax .set_ylim (- 2 , 2 )
351+ plt .show ()
343352
344353###############################################################################
345354# In this basic example, both *xy* and *xytext* are in data coordinates.
@@ -358,6 +367,7 @@ def my_plotter(ax, data1, data2, param_dict):
358367ax .plot (np .arange (len (data2 )), data2 , label = 'data2' )
359368ax .plot (np .arange (len (data3 )), data3 , 'd' , label = 'data3' )
360369ax .legend ()
370+ plt .show ()
361371
362372##############################################################################
363373# Legends in Matplotlib are quite flexible in layout, placement, and what
@@ -387,6 +397,7 @@ def my_plotter(ax, data1, data2, param_dict):
387397
388398axs [1 ].set_yscale ('log' )
389399axs [1 ].plot (xdata , data )
400+ plt .show ()
390401
391402##############################################################################
392403# The scale sets the mapping from data values to spacing along the Axis. This
@@ -408,6 +419,7 @@ def my_plotter(ax, data1, data2, param_dict):
408419axs [1 ].set_xticks (np .arange (0 , 100 , 30 ), ['zero' , '30' , 'sixty' , '90' ])
409420axs [1 ].set_yticks ([- 1.5 , 0 , 1.5 ]) # note that we don't need to specify labels
410421axs [1 ].set_title ('Manual ticks' )
422+ plt .show ()
411423
412424##############################################################################
413425# Different scales can have different locators and formatters; for instance
@@ -428,6 +440,7 @@ def my_plotter(ax, data1, data2, param_dict):
428440 np .timedelta64 (1 , 'h' ))
429441data = np .cumsum (np .random .randn (len (dates )))
430442ax .plot (dates , data )
443+ plt .show ()
431444
432445##############################################################################
433446# For more information see the date examples
@@ -440,6 +453,7 @@ def my_plotter(ax, data1, data2, param_dict):
440453categories = ['turnips' , 'rutabega' , 'cucumber' , 'pumpkins' ]
441454
442455ax .bar (categories , np .random .rand (len (categories )))
456+ plt .show ()
443457
444458##############################################################################
445459# One caveat about categorical plotting is that some methods of parsing
@@ -473,6 +487,7 @@ def my_plotter(ax, data1, data2, param_dict):
473487pc = axs [1 , 1 ].scatter (data1 , data2 , c = data3 , cmap = 'RdBu_r' )
474488fig .colorbar (pc , ax = axs [1 , 1 ], extend = 'both' )
475489axs [1 , 1 ].set_title ('scatter()' )
490+ plt .show ()
476491
477492##############################################################################
478493# Colormaps
0 commit comments