8000 DOC: add show to each example · matplotlib/matplotlib@94d2fd5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 94d2fd5

Browse files
committed
DOC: add show to each example
1 parent fd83646 commit 94d2fd5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tutorials/introductory/usage.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
fig, ax = plt.subplots() # Create a figure containing a single axes.
2828
ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the axes.
29+
plt.show()
2930

3031
###############################################################################
3132
# .. _figure_parts:
@@ -124,6 +125,7 @@
124125
ax.scatter('a', 'b', c='c', s='d', data=data)
125126
ax.set_xlabel('entry a')
126127
ax.set_ylabel('entry b')
128+
plt.show()
127129

128130
##############################################################################
129131
# .. _coding_styles:
@@ -154,6 +156,7 @@
154156
ax.set_ylabel('y label') # Add a y-label to the axes.
155157
ax.set_title("Simple Plot") # Add a title to the axes.
156158
ax.legend() # Add a legend.
159+
plt.show()
157160

158161
################################################################# 10000 ##############
159162
# or the pyplot-style:
@@ -168,6 +171,7 @@
168171
plt.ylabel('y label')
169172
plt.title("Simple Plot")
170173
plt.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):
209213
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(5, 2.7))
210214
my_plotter(ax1, data1, data2, {'marker': 'x'})
211215
my_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):
231236
ax.plot(x, np.cumsum(data1), color='blue', linewidth=3, linestyle='--')
232237
l, = ax.plot(x, np.cumsum(data2), color='orange', linewidth=2)
233238
l.set_linestyle(':')
239+
plt.show()
234240

235241
###############################################################################
236242
# Colors
@@ -245,6 +251,7 @@ def my_plotter(ax, data1, data2, param_dict):
245251
fig, ax = plt.subplots(figsize=(5, 2.7))
246252
x = np.arange(len(data1))
247253
ax.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):
269276
ax.plot(data3, 'v', label='data3')
270277
ax.plot(data4, 's', label='data4')
271278
ax.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

342350
ax.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):
358367
ax.plot(np.arange(len(data2)), data2, label='data2')
359368
ax.plot(np.arange(len(data3)), data3, 'd', label='data3')
360369
ax.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

388398
axs[1].set_yscale('log')
389399
axs[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):
408419
axs[1].set_xticks(np.arange(0, 100, 30), ['zero', '30', 'sixty', '90'])
409420
axs[1].set_yticks([-1.5, 0, 1.5]) # note that we don't need to specify labels
410421
axs[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'))
429441
data = np.cumsum(np.random.randn(len(dates)))
430442
ax.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):
440453
categories = ['turnips', 'rutabega', 'cucumber', 'pumpkins']
441454

442455
ax.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):
473487
pc = axs[1, 1].scatter(data1, data2, c=data3, cmap='RdBu_r')
474488
fig.colorbar(pc, ax=axs[1, 1], extend='both')
475489
axs[1, 1].set_title('scatter()')
490+
plt.show()
476491

477492
##############################################################################
478493
# Colormaps

0 commit comments

Comments
 (0)
0