Skip to content

Commit 17576a2

Browse files
committed
DOC: Drop extraneous code from what's new plots
We don't expect these to be fully copy-pastable, as they are focused on the element that specifically changed.
1 parent 35292c9 commit 17576a2

1 file changed

Lines changed: 0 additions & 53 deletions

File tree

doc/release/prev_whats_new/whats_new_3.11.0.rst

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,6 @@ allows more than one arrow to be added to each streamline:
214214
:include-source:
215215
:alt: One chart showing a streamplot. Each streamline has three arrows.
216216

217-
import matplotlib.pyplot as plt
218-
import numpy as np
219-
220217
w = 3
221218
Y, X = np.mgrid[-w:w:100j, -w:w:100j]
222219
U = -1 - X**2 + Y
@@ -225,8 +222,6 @@ allows more than one arrow to be added to each streamline:
225222
fig, ax = plt.subplots()
226223
ax.streamplot(X, Y, U, V, num_arrows=3)
227224

228-
plt.show()
229-
230225
``violinplot`` now accepts color arguments
231226
------------------------------------------
232227

@@ -287,8 +282,6 @@ For more examples, see :doc:`/gallery/pie_and_polar_charts/pie_label`.
287282
A pie chart with three labels on each wedge, showing a food type, number, and
288283
fraction associated with the wedge.
289284

290-
import matplotlib.pyplot as plt
291-
292285
data = [36, 24, 8, 12]
293286
labels = ['spam', 'eggs', 'bacon', 'sausage']
294287

@@ -320,8 +313,6 @@ By using negative angles (or corresponding reflex angles) for *head_angle*, arro
320313
left; the arrows on the right have the shaft on the right; the arrows in the
321314
middle have shafts on both sides.
322315

323-
import matplotlib.pyplot as plt
324-
325316
plt.text(0.2, 0.8, "LArrow", ha='center', size=16,
326317
bbox=dict(boxstyle="larrow, pad=0.3, head_angle=150"))
327318
plt.text(0.2, 0.2, "LArrow", ha='center', size=16,
@@ -336,8 +327,6 @@ By using negative angles (or corresponding reflex angles) for *head_angle*, arro
336327
bbox=dict(boxstyle="rarrow, pad=0.3, head_width=2, head_angle=-90"))
337328
plt.axis("off")
338329

339-
plt.show()
340-
341330
*borderpad* accepts a tuple for separate x/y padding
342331
----------------------------------------------------
343332

@@ -403,15 +392,13 @@ alternating edge colors ensure the patch boundary remains visible.
403392
A rectangle with a dashed orange edge and blue gaps, demonstrating the
404393
edgegapcolor feature.
405394

406-
import matplotlib.pyplot as plt
407395
from matplotlib.patches import Rectangle
408396

409397
fig, ax = plt.subplots()
410398
rect = Rectangle((0.1, 0.1), 0.6, 0.6, fill=False,
411399
edgecolor='orange', edgegapcolor='blue',
412400
linestyle='--', linewidth=3)
413401
ax.add_patch(rect)
414-
plt.show()
415402

416403
Separated ``hatchcolor`` from ``edgecolor``
417404
-------------------------------------------
@@ -434,7 +421,6 @@ fallback to :rc:`hatch.color` if the patch did not have an edge color.
434421
hatchcolor='green' when the hatchcolor is not set.
435422

436423
import matplotlib as mpl
437-
import matplotlib.pyplot as plt
438424
from matplotlib.patches import Rectangle
439425

440426
fig, ax = plt.subplots()
@@ -477,8 +463,6 @@ fallback to :rc:`hatch.color` if the patch did not have an edge color.
477463
ax.annotate("hatch.color='black'",
478464
xy=(.5, 1.03), xycoords=patch4, ha='center', va='bottom')
479465

480-
plt.show()
481-
482466
For collections, a sequence of colors can be passed to the *hatchcolor* parameter which
483467
will be cycled through for each hatch, similar to *facecolor* and *edgecolor*.
484468

@@ -495,9 +479,6 @@ alpha value of the collection. This behavior has been changed such that, if both
495479
blue, orange, and green, respectively. After the first three markers, the colors
496480
are cycled through again.
497481

498-
import matplotlib.pyplot as plt
499-
import numpy as np
500-
501482
np.random.seed(19680801)
502483

503484
fig, ax = plt.subplots()
@@ -516,8 +497,6 @@ alpha value of the collection. This behavior has been changed such that, if both
516497
edgecolor="black",
517498
)
518499

519-
plt.show()
520-
521500
Axis and Ticks
522501
==============
523502

@@ -545,8 +524,6 @@ labels.
545524
:include-source:
546525
:alt: Example of rotated xtick and ytick labels.
547526

548-
import matplotlib.pyplot as plt
549-
550527
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(7, 3.5), layout='constrained')
551528

552529
pos = range(5)
@@ -558,8 +535,6 @@ labels.
558535
ax2.yaxis.tick_right()
559536
ax2.set_yticks(pos, labels, rotation=45, rotation_mode='ytick')
560537

561-
plt.show()
562-
563538
Improved selection of log-scale ticks
564539
-------------------------------------
565540

@@ -596,14 +571,11 @@ Or, when creating plots, you can pass it explicitly:
596571

597572
.. plot::
598573

599-
import matplotlib.pyplot as plt
600-
601574
colors = plt.colormaps['okabe_ito'].colors
602575
x = range(5)
603576
for i, c in enumerate(colors):
604577
plt.plot(x, [v*(i+1) for v in x], color=c, label=f'line {i}')
605578
plt.legend()
606-
plt.show()
607579

608580
Six and eight color Petroff color cycles
609581
----------------------------------------
@@ -1059,8 +1031,6 @@ for the major and minor gridlines, respectively.
10591031
:alt: Modifying the gridlines using the new options `rcParams`
10601032

10611033
import matplotlib as mpl
1062-
import matplotlib.pyplot as plt
1063-
10641034

10651035
# Set visibility for major and minor gridlines
10661036
mpl.rcParams["axes.grid"] = True
@@ -1078,8 +1048,6 @@ for the major and minor gridlines, respectively.
10781048

10791049
plt.plot([0, 1], [0, 1])
10801050

1081-
plt.show()
1082-
10831051
``axes.prop_cycle`` rcParam security improvements
10841052
-------------------------------------------------
10851053

@@ -1113,12 +1081,9 @@ frame line width directly, overriding the rcParam value.
11131081
:include-source:
11141082
:alt: A line plot with a legend showing a thick border around the legend box.
11151083

1116-
import matplotlib.pyplot as plt
1117-
11181084
fig, ax = plt.subplots()
11191085
ax.plot([1, 2, 3], label='data')
11201086
ax.legend(linewidth=2.0) # Thick legend box edge
1121-
plt.show()
11221087

11231088
``PatchCollection`` legends now supported
11241089
-----------------------------------------
@@ -1133,7 +1098,6 @@ requiring users to create manual legend entries.
11331098
The legend entry displays a rectangle matching the visual properties (colors,
11341099
line styles, line widths) of the first patch in the collection.
11351100

1136-
import matplotlib.pyplot as plt
11371101
import matplotlib.patches as mpatches
11381102
from matplotlib.collections import PatchCollection
11391103

@@ -1142,7 +1106,6 @@ requiring users to create manual legend entries.
11421106
pc = PatchCollection(patches, facecolor='blue', edgecolor='black', label='My patches')
11431107
ax.add_collection(pc)
11441108
ax.legend() # Now displays the label "My patches"
1145-
plt.show()
11461109

11471110
Widgets and Interactivity
11481111
=========================
@@ -1176,8 +1139,6 @@ See :doc:`/gallery/widgets/radio_buttons_grid` for a ``(rows, cols)`` example.
11761139
:include-source:
11771140
:alt: Multiple sine waves with checkboxes to toggle their visibility.
11781141

1179-
import matplotlib.pyplot as plt
1180-
import numpy as np
11811142
from matplotlib.widgets import CheckButtons
11821143

11831144
t = np.arange(0.0, 2.0, 0.01)
@@ -1215,7 +1176,6 @@ See :doc:`/gallery/widgets/radio_buttons_grid` for a ``(rows, cols)`` example.
12151176
fig.canvas.draw_idle()
12161177

12171178
check.on_clicked(callback)
1218-
plt.show()
12191179

12201180
Callable *valfmt* for ``Slider`` and ``RangeSlider``
12211181
----------------------------------------------------
@@ -1247,9 +1207,6 @@ just like 2D axes. Use `~.Axes3D.set_xscale`, `~.Axes3D.set_yscale`, and
12471207
:include-source:
12481208
:alt: A 3D plot with a linear x-axis, logarithmic y-axis, and symlog z-axis.
12491209

1250-
import matplotlib.pyplot as plt
1251-
import numpy as np
1252-
12531210
# A sine chirp with increasing frequency and amplitude
12541211
x = np.linspace(0, 1, 400) # time
12551212
y = 10 ** (2 * x) # frequency, growing exponentially from 1 to 100 Hz
@@ -1267,8 +1224,6 @@ just like 2D axes. Use `~.Axes3D.set_xscale`, `~.Axes3D.set_yscale`, and
12671224
ax.set_yscale('log')
12681225
ax.set_zscale('symlog')
12691226

1270-
plt.show()
1271-
12721227
See `matplotlib.scale` for details on all available scales and their parameters.
12731228

12741229
Snapping 3D rotation angles with Control key
@@ -1307,8 +1262,6 @@ A simple example:
13071262
:include-source:
13081263
:alt: A 3D scatter plot with depth-shading enabled.
13091264

1310-
import matplotlib.pyplot as plt
1311-
13121265
fig = plt.figure()
13131266
ax = fig.add_subplot(projection="3d")
13141267

@@ -1324,8 +1277,6 @@ A simple example:
13241277
)
13251278
ax.view_init(elev=10, azim=-150, roll=0)
13261279

1327-
plt.show()
1328-
13291280
3D performance improvements
13301281
---------------------------
13311282

@@ -1377,9 +1328,7 @@ calling `~.Axes.violinplot`.
13771328
Example showing violin_stats followed by violin gives the same result as
13781329
violinplot.
13791330

1380-
import matplotlib.pyplot as plt
13811331
from matplotlib.cbook import violin_stats
1382-
import numpy as np
13831332

13841333
rng = np.random.default_rng(19680801)
13851334
data = rng.normal(size=(10, 3))
@@ -1394,5 +1343,3 @@ calling `~.Axes.violinplot`.
13941343
vstats = violin_stats(data)
13951344
ax2.violin(vstats)
13961345
ax2.set_title('Two Steps')
1397-
1398-
plt.show()

0 commit comments

Comments
 (0)