Skip to content

Commit f7b3c2e

Browse files
committed
Add more images and code samples to 3.5 What's new
1 parent b9065f7 commit f7b3c2e

File tree

1 file changed

+94
-5
lines changed

1 file changed

+94
-5
lines changed

doc/users/prev_whats_new/whats_new_3.5.0.rst

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ Two new styles ``']->'`` and ``'<-['`` are also added via this mechanism.
7777
`.ConnectionPatch`, which accepts arrow styles though its *arrowstyle*
7878
parameter, also accepts these new styles.
7979

80+
.. plot::
81+
82+
import matplotlib.patches as mpatches
83+
84+
fig, ax = plt.subplots(figsize=(4, 4))
85+
86+
ax.plot([0.75, 0.75], [0.25, 0.75], 'ok')
87+
ax.set(xlim=(0, 1), ylim=(0, 1), title='New ArrowStyle options')
88+
89+
ax.annotate(']->', (0.75, 0.25), (0.25, 0.25),
90+
arrowprops=dict(
91+
arrowstyle=']->', connectionstyle="arc3,rad=-0.05",
92+
shrinkA=5, shrinkB=5,
93+
),
94+
bbox=dict(boxstyle='square', fc='w'), size='large')
95+
96+
ax.annotate('<-[', (0.75, 0.75), (0.25, 0.75),
97+
arrowprops=dict(
98+
arrowstyle='<-[', connectionstyle="arc3,rad=-0.05",
99+
shrinkA=5, shrinkB=5,
100+
),
101+
bbox=dict(boxstyle='square', fc='w'), size='large')
102+
80103
Setting collection offset transform after initialization
81104
--------------------------------------------------------
82105

@@ -130,6 +153,11 @@ A new keyword argument *interpolation_stage* is provided for
130153
happens. The default is the current behaviour of "data", with the alternative
131154
being "rgba" for the newly-available behavior.
132155

156+
.. figure:: /gallery/images_contours_and_fields/images/sphx_glr_image_antialiasing_001.png
157+
:target: /gallery/images_contours_and_fields/image_antialiasing.html
158+
159+
Example of the interpolation stage options.
160+
133161
For more details see the discussion of the new keyword argument in
134162
:doc:`/gallery/images_contours_and_fields/image_antialiasing`.
135163

@@ -153,11 +181,19 @@ Settings tick positions and labels simultaneously in ``set_ticks``
153181
and labels simultaneously.
154182

155183
Previously, setting tick labels was done using `.Axis.set_ticklabels` (or
156-
the corresponding `.Axes.set_xticklabels` / `.Axes.set_yticklabels`). This
184+
the corresponding `.Axes.set_xticklabels` / `.Axes.set_yticklabels`); this
157185
usually only makes sense if tick positions were previously fixed with
158-
`~.Axis.set_ticks`. The combined functionality is now available in
159-
`~.Axis.set_ticks`. The use of `.Axis.set_ticklabels` is discouraged, but it
160-
will stay available for backward compatibility.
186+
`~.Axis.set_ticks`::
187+
188+
ax.set_xticks([1, 2, 3])
189+
ax.set_xticklabels(['a', 'b', 'c'])
190+
191+
The combined functionality is now available in `~.Axis.set_ticks`::
192+
193+
ax.set_xticks([1, 2, 3], ['a', 'b', 'c'])
194+
195+
The use of `.Axis.set_ticklabels` is discouraged, but it will stay available
196+
for backward compatibility.
161197

162198
Note: This addition makes the API of `~.Axis.set_ticks` also more similar to
163199
`.pyplot.xticks` / `.pyplot.yticks`, which already had the additional *labels*
@@ -241,7 +277,6 @@ A new :rc:`legend.labelcolor` sets the default *labelcolor* argument for
241277
'mfc'), or 'markeredgecolor' (or 'mec') will cause the legend text to match the
242278
corresponding color of marker.
243279

244-
245280
.. plot::
246281

247282
plt.rcParams['legend.labelcolor'] = 'linecolor'
@@ -269,12 +304,66 @@ The `~mpl_toolkits.mplot3d.axes3d.Axes3D` class now has *computed_zorder*
269304
parameter. When set to False, Artists are drawn using their ``zorder``
270305
attribute.
271306

307+
.. plot::
308+
309+
import matplotlib.patches as mpatches
310+
from mpl_toolkits.mplot3d import art3d
311+
312+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6.4, 3),
313+
subplot_kw=dict(projection='3d'))
314+
315+
ax1.set_title('computed_zorder = True (default)')
316+
ax2.set_title('computed_zorder = False')
317+
ax2.computed_zorder = False
318+
319+
corners = ((0, 0, 0), (0, 5, 0), (5, 5, 0), (5, 0, 0))
320+
for ax in (ax1, ax2):
321+
tri = art3d.Poly3DCollection([corners],
322+
facecolors='white',
323+
edgecolors='black',
324+
zorder=1)
325+
ax.add_collection3d(tri)
326+
line, = ax.plot((2, 2), (2, 2), (0, 4), c='red', zorder=2,
327+
label='zorder=2')
328+
points = ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10,
329+
label='zorder=10')
330+
331+
ax.set_xlim((0, 5))
332+
ax.set_ylim((0, 5))
333+
ax.set_zlim((0, 2.5))
334+
335+
plane = mpatches.Patch(facecolor='white', edgecolor='black',
336+
label='zorder=1')
337+
fig.legend(handles=[plane, line, points], loc='lower center')
338+
272339
Allow changing the vertical axis in 3d plots
273340
----------------------------------------------
274341

275342
`~mpl_toolkits.mplot3d.axes3d.Axes3D.view_init` now has the parameter
276343
*vertical_axis* which allows switching which axis is aligned vertically.
277344

345+
.. plot::
346+
347+
Nphi, Nr = 18, 8
348+
phi = np.linspace(0, np.pi, Nphi)
349+
r = np.arange(Nr)
350+
phi = np.tile(phi, Nr).flatten()
351+
r = np.repeat(r, Nphi).flatten()
352+
353+
x = r * np.sin(phi)
354+
y = r * np.cos(phi)
355+
z = Nr - r
356+
357+
fig, axs = plt.subplots(1, 3, figsize=(7, 3),
358+
subplot_kw=dict(projection='3d'),
359+
gridspec_kw=dict(wspace=0.4, left=0.08, right=0.98,
360+
bottom=0, top=1))
361+
for vert_a, ax in zip(['z', 'y', 'x'], axs):
362+
pc = ax.scatter(x, y, z, c=z)
363+
ax.view_init(azim=30, elev=30, vertical_axis=vert_a)
364+
ax.set(xlabel='x', ylabel='y', zlabel='z',
365+
title=f'vertical_axis={vert_a!r}')
366+
278367
Interactive tool improvements
279368
=============================
280369

0 commit comments

Comments
 (0)