Skip to content

Commit d0671d9

Browse files
committed
Embed whats_new_* examples in What's new pages.
There's no need for these to be separate as we can use `.. plot::` to embed them, and there already exist examples that show these things off.
1 parent 95b4527 commit d0671d9

File tree

10 files changed

+147
-304
lines changed

10 files changed

+147
-304
lines changed

.flake8

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ per-file-ignores =
213213
examples/pyplots/pyplot_two_subplots.py: E402
214214
examples/pyplots/text_commands.py: E402
215215
examples/pyplots/text_layout.py: E402
216-
examples/pyplots/whats_new_1_subplot3d.py: E402
217-
examples/pyplots/whats_new_98_4_fill_between.py: E402
218-
examples/pyplots/whats_new_98_4_legend.py: E402
219-
examples/pyplots/whats_new_99_axes_grid.py: E402
220-
examples/pyplots/whats_new_99_mplot3d.py: E402
221-
examples/pyplots/whats_new_99_spines.py: E402
222216
examples/scales/power_norm.py: E402
223217
examples/scales/scales.py: E402
224218
examples/shapes_and_collections/artist_reference.py: E402

doc/users/prev_whats_new/whats_new_0.98.4.rst

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ multiple columns and rows, as well as fancy box drawing. See
3030
:func:`~matplotlib.pyplot.legend` and
3131
:class:`matplotlib.legend.Legend`.
3232

33-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_legend_001.png
34-
:target: ../../gallery/pyplots/whats_new_98_4_legend.html
35-
:align: center
36-
:scale: 50
33+
.. plot::
34+
35+
ax = plt.subplot()
36+
t1 = np.arange(0.0, 1.0, 0.01)
37+
for n in [1, 2, 3, 4]:
38+
plt.plot(t1, t1**n, label=f"n={n}")
39+
40+
leg = plt.legend(loc='best', ncol=2, mode="expand", shadow=True, fancybox=True)
41+
leg.get_frame().set_alpha(0.5)
42+
43+
plt.show()
3744

38-
What's New 98 4 Legend
3945

4046
.. _fancy-annotations:
4147

@@ -145,12 +151,20 @@ can pass an *x* array and a *ylower* and *yupper* array to fill
145151
between, and an optional *where* argument which is a logical mask
146152
where you want to do the filling.
147153

148-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_fill_between_001.png
149-
:target: ../../gallery/pyplots/whats_new_98_4_fill_between.html
150-
:align: center
151-
:scale: 50
154+
.. plot::
155+
156+
x = np.arange(-5, 5, 0.01)
157+
y1 = -5*x*x + x + 10
158+
y2 = 5*x*x + x
159+
160+
fig, ax = plt.subplots()
161+
ax.plot(x, y1, x, y2, color='black')
162+
ax.fill_between(x, y1, y2, where=(y2 > y1), facecolor='yellow', alpha=0.5)
163+
ax.fill_between(x, y1, y2, where=(y2 <= y1), facecolor='red', alpha=0.5)
164+
ax.set_title('Fill Between')
165+
166+
plt.show()
152167

153-
What's New 98 4 Fill Between
154168

155169
Lots more
156170
---------

doc/users/prev_whats_new/whats_new_0.99.rst

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,29 @@ working with paths and transformations: :doc:`/tutorials/advanced/path_tutorial`
2222
mplot3d
2323
--------
2424

25-
2625
Reinier Heeres has ported John Porter's mplot3d over to the new
2726
matplotlib transformations framework, and it is now available as a
2827
toolkit mpl_toolkits.mplot3d (which now comes standard with all mpl
2928
installs). See :ref:`mplot3d-examples-index` and
3029
:ref:`toolkit_mplot3d-tutorial`
3130

32-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_mplot3d_001.png
33-
:target: ../../gallery/pyplots/whats_new_99_mplot3d.html
34-
:align: center
35-
:scale: 50
31+
.. plot::
32+
33+
from matplotlib import cm
34+
from mpl_toolkits.mplot3d import Axes3D
35+
36+
X = np.arange(-5, 5, 0.25)
37+
Y = np.arange(-5, 5, 0.25)
38+
X, Y = np.meshgrid(X, Y)
39+
R = np.sqrt(X**2 + Y**2)
40+
Z = np.sin(R)
41+
42+
fig = plt.figure()
43+
ax = Axes3D(fig, auto_add_to_figure=False)
44+
fig.add_axes(ax)
45+
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)
3646

37-
What's New 99 Mplot3d
47+
plt.show()
3848

3949
.. _whats-new-axes-grid:
4050

@@ -48,12 +58,49 @@ new mpl installs. See :ref:`axes_grid1-examples-index`,
4858
:ref:`axisartist-examples-index`, :ref:`axes_grid1_users-guide-index` and
4959
:ref:`axisartist_users-guide-index`
5060

51-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_axes_grid_001.png
52-
:target: ../../gallery/pyplots/whats_new_99_axes_grid.html
53-
:align: center
54-
:scale: 50
61+
.. plot::
62+
63+
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
64+
65+
66+
def get_demo_image():
67+
# prepare image
68+
delta = 0.5
69+
70+
extent = (-3, 4, -4, 3)
71+
x = np.arange(-3.0, 4.001, delta)
72+
y = np.arange(-4.0, 3.001, delta)
73+
X, Y = np.meshgrid(x, y)
74+
Z1 = np.exp(-X**2 - Y**2)
75+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
76+
Z = (Z1 - Z2) * 2
77+
78+
return Z, extent
79+
80+
81+
def get_rgb():
82+
Z, extent = get_demo_image()
83+
84+
Z[Z < 0] = 0.
85+
Z = Z / Z.max()
86+
87+
R = Z[:13, :13]
88+
G = Z[2:, 2:]
89+
B = Z[:13, 2:]
90+
91+
return R, G, B
5592

56-
What's New 99 Axes Grid
93+
94+
fig = plt.figure()
95+
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
96+
97+
r, g, b = get_rgb()
98+
ax.imshow_rgb(r, g, b, origin="lower")
99+
100+
ax.RGB.set_xlim(0., 9.5)
101+
ax.RGB.set_ylim(0.9, 10.6)
102+
103+
plt.show()
57104

58105
.. _whats-new-spine:
59106

@@ -68,9 +115,47 @@ well as "detach" the spine to offset it away from the data. See
68115
:doc:`/gallery/ticks_and_spines/spine_placement_demo` and
69116
:class:`matplotlib.spines.Spine`.
70117

71-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_spines_001.png
72-
:target: ../../gallery/pyplots/whats_new_99_spines.html
73-
:align: center
74-
:scale: 50
118+
.. plot::
119+
120+
def adjust_spines(ax, spines):
121+
for loc, spine in ax.spines.items():
122+
if loc in spines:
123+
spine.set_position(('outward', 10)) # outward by 10 points
124+
else:
125+
spine.set_color('none') # don't draw spine
126+
127+
# turn off ticks where there is no spine
128+
if 'left' in spines:
129+
ax.yaxis.set_ticks_position('left')
130+
else:
131+
# no yaxis ticks
132+
ax.yaxis.set_ticks([])
133+
134+
if 'bottom' in spines:
135+
ax.xaxis.set_ticks_position('bottom')
136+
else:
137+
# no xaxis ticks
138+
ax.xaxis.set_ticks([])
139+
140+
fig = plt.figure()
141+
142+
x = np.linspace(0, 2*np.pi, 100)
143+
y = 2*np.sin(x)
144+
145+
ax = fig.add_subplot(2, 2, 1)
146+
ax.plot(x, y)
147+
adjust_spines(ax, ['left'])
148+
149+
ax = fig.add_subplot(2, 2, 2)
150+
ax.plot(x, y)
151+
adjust_spines(ax, [])
152+
153+
ax = fig.add_subplot(2, 2, 3)
154+
ax.plot(x, y)
155+
adjust_spines(ax, ['left', 'bottom'])
156+
157+
ax = fig.add_subplot(2, 2, 4)
158+
ax.plot(x, y)
159+
adjust_spines(ax, ['bottom'])
75160

76-
What's New 99 Spines
161+
plt.show()

doc/users/prev_whats_new/whats_new_1.0.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,29 @@ supporting mixing of 2D and 3D graphs in the same figure, and/or
9292
multiple 3D graphs in a single figure, using the "projection" keyword
9393
argument to add_axes or add_subplot. Thanks Ben Root.
9494

95-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_1_subplot3d_001.png
96-
:target: ../../gallery/pyplots/whats_new_1_subplot3d.html
97-
:align: center
98-
:scale: 50
95+
.. plot::
96+
97+
from mpl_toolkits.mplot3d.axes3d import get_test_data
98+
99+
fig = plt.figure()
100+
101+
X = np.arange(-5, 5, 0.25)
102+
Y = np.arange(-5, 5, 0.25)
103+
X, Y = np.meshgrid(X, Y)
104+
R = np.sqrt(X**2 + Y**2)
105+
Z = np.sin(R)
106+
ax = fig.add_subplot(1, 2, 1, projection='3d')
107+
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis',
108+
linewidth=0, antialiased=False)
109+
ax.set_zlim3d(-1.01, 1.01)
110+
111+
fig.colorbar(surf, shrink=0.5, aspect=5)
112+
113+
X, Y, Z = get_test_data(0.05)
114+
ax = fig.add_subplot(1, 2, 2, projection='3d')
115+
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
99116

100-
What's New 1 Subplot3d
117+
plt.show()
101118

102119
tick_params
103120
-----------

examples/pyplots/whats_new_1_subplot3d.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

examples/pyplots/whats_new_98_4_fill_between.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/pyplots/whats_new_98_4_legend.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)