26
26
27
27
fig , ax = plt .subplots () # Create a figure containing a single axes.
28
28
ax .plot ([1 , 2 , 3 , 4 ], [1 , 4 , 2 , 3 ]) # Plot some data on the axes.
29
+ plt .show ()
29
30
30
31
###############################################################################
31
32
# .. _figure_parts:
124
125
ax .scatter ('a' , 'b' , c = 'c' , s = 'd' , data = data )
125
126
ax .set_xlabel ('entry a' )
126
127
ax .set_ylabel ('entry b' )
128
+ plt .show ()
127
129
128
130
##############################################################################
129
131
# .. _coding_styles:
154
156
ax .set_ylabel ('y label' ) # Add a y-label to the axes.
155
157
ax .set_title ("Simple Plot" ) # Add a title to the axes.
156
158
ax .legend () # Add a legend.
159
+ plt .show ()
157
160
158
161
#################################################################
10000
##############
159
162
# or the pyplot-style:
168
171
plt .ylabel ('y label' )
169
172
plt .title ("Simple Plot" )
170
173
plt .legend ()
174
+ plt .show ()
171
175
172
176
###############################################################################
173
177
# (In addition, there is a third approach, for the case when embedding
@@ -209,6 +213,7 @@ def my_plotter(ax, data1, data2, param_dict):
209
213
fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (5 , 2.7 ))
210
214
my_plotter (ax1 , data1 , data2 , {'marker' : 'x' })
211
215
my_plotter (ax2 , data3 , data4 , {'marker' : 'o' })
216
+ plt .show ()
212
217
213
218
###############################################################################
214
219
# 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):
231
236
ax .plot (x , np .cumsum (data1 ), color = 'blue' , linewidth = 3 , linestyle = '--' )
232
237
l , = ax .plot (x , np .cumsum (data2 ), color = 'orange' , linewidth = 2 )
233
238
l .set_linestyle (':' )
239
+ plt .show ()
234
240
235
241
###############################################################################
236
242
# Colors
@@ -245,6 +251,7 @@ def my_plotter(ax, data1, data2, param_dict):
245
251
fig , ax = plt .subplots (figsize = (5 , 2.7 ))
246
252
x = np .arange (len (data1 ))
247
253
ax .scatter (data1 , data2 , s = 50 , facecolor = 'C0' , edgecolor = 'k' )
254
+ plt .show ()
248
255
249
256
###############################################################################
250
257
# Linewidths, linestyles, and markersizes
@@ -269,6 +276,7 @@ def my_plotter(ax, data1, data2, param_dict):
269
276
ax .plot (data3 , 'v' , label = 'data3' )
270
277
ax .plot (data4 , 's' , label = 'data4' )
271
278
ax .legend ()
279
+ plt .show ()
272
280
273
281
################################################################################
274
282
#
@@ -340,6 +348,7 @@ def my_plotter(ax, data1, data2, param_dict):
340
348
arrowprops = dict (facecolor = 'black' , shrink = 0.05 ))
341
349
342
350
ax .set_ylim (- 2 , 2 )
351
+ plt .show ()
343
352
344
353
###############################################################################
345
354
# In this basic example, both *xy* and *xytext* are in data coordinates.
@@ -358,6 +367,7 @@ def my_plotter(ax, data1, data2, param_dict):
358
367
ax .plot (np .arange (len (data2 )), data2 , label = 'data2' )
359
368
ax .plot (np .arange (len (data3 )), data3 , 'd' , label = 'data3' )
360
369
ax .legend ()
370
+ plt .show ()
361
371
362
372
##############################################################################
363
373
# Legends in Matplotlib are quite flexible in layout, placement, and what
@@ -387,6 +397,7 @@ def my_plotter(ax, data1, data2, param_dict):
387
397
388
398
axs [1 ].set_yscale ('log' )
389
399
axs [1 ].plot (xdata , data )
400
+ plt .show ()
390
401
391
402
##############################################################################
392
403
# 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):
408
419
axs [1 ].set_xticks (np .arange (0 , 100 , 30 ), ['zero' , '30' , 'sixty' , '90' ])
409
420
axs [1 ].set_yticks ([- 1.5 , 0 , 1.5 ]) # note that we don't need to specify labels
410
421
axs [1 ].set_title ('Manual ticks' )
422
+ plt .show ()
411
423
412
424
##############################################################################
413
425
# Different scales can have different locators and formatters; for instance
@@ -428,6 +440,7 @@ def my_plotter(ax, data1, data2, param_dict):
428
440
np .timedelta64 (1 , 'h' ))
429
441
data = np .cumsum (np .random .randn (len (dates )))
430
442
ax .plot (dates , data )
443
+ plt .show ()
431
444
432
445
##############################################################################
433
446
# For more information see the date examples
@@ -440,6 +453,7 @@ def my_plotter(ax, data1, data2, param_dict):
440
453
categories = ['turnips' , 'rutabega' , 'cucumber' , 'pumpkins' ]
441
454
442
455
ax .bar (categories , np .random .rand (len (categories )))
456
+ plt .show ()
443
457
444
458
##############################################################################
445
459
# One caveat about categorical plotting is that some methods of parsing
@@ -473,6 +487,7 @@ def my_plotter(ax, data1, data2, param_dict):
473
487
pc = axs [1 , 1 ].scatter (data1 , data2 , c = data3 , cmap = 'RdBu_r' )
474
488
fig .colorbar (pc , ax = axs [1 , 1 ], extend = 'both' )
475
489
axs [1 , 1 ].set_title ('scatter()' )
490
+ plt .show ()
476
491
477
492
##############################################################################
478
493
# Colormaps
0 commit comments