Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fb42b1

Browse files
committed
DOC: More edits to the 3.3 what's new from review.
1 parent e6648a7 commit 2fb42b1

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

doc/users/prev_whats_new/whats_new_3.3.0.rst

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ The `.Figure` class has a provisional method to generate complex grids of named
2222
:include-source: True
2323

2424
axd = plt.figure(constrained_layout=True).subplot_mosaic(
25-
[["Top", "Top", "Edge"],
26-
["Left", ".", "Edge"]]
25+
[['.', 'histx'],
26+
['histy', 'scat']]
2727
)
2828
for k, ax in axd.items():
2929
ax.text(0.5, 0.5, k,
@@ -343,16 +343,45 @@ generated and used. For a function a `~.ticker.FuncFormatter` is automatically
343343
generated and used. In other words,
344344
::
345345

346-
ax.xaxis.set_major_formatter('price: {x:02}')
347-
ax.xaxis.set_minor_formatter(lambda x, pos: 'low' if x < 2 else 'high')
346+
ax.xaxis.set_major_formatter('{x} km')
347+
ax.xaxis.set_minor_formatter(lambda x, pos: str(x-5))
348348

349349
are shortcuts for::
350350

351351
import matplotlib.ticker as mticker
352352

353-
ax.xaxis.set_major_formatter(mticker.StrMethodFormatter('price: {x:02}'))
353+
ax.xaxis.set_major_formatter(mticker.StrMethodFormatter('{x} km'))
354354
ax.xaxis.set_minor_formatter(
355-
mticker.FuncFormatter(lambda x, pos: 'low' if x < 2 else 'high'))
355+
mticker.FuncFormatter(lambda x, pos: str(x-5))
356+
357+
.. plot::
358+
359+
from matplotlib import ticker
360+
361+
titles = ["'{x} km'", "lambda x, pos: str(x-5)"]
362+
formatters = ['{x} km', lambda x, pos: str(x-5)]
363+
364+
fig, axs = plt.subplots(2, 1, figsize=(8, 2), constrained_layout=True)
365+
366+
for ax, title, formatter in zip(axs, titles, formatters):
367+
# only show the bottom spine
368+
ax.yaxis.set_major_locator(ticker.NullLocator())
369+
for spine in ['top', 'left', 'right']:
370+
ax.spines[spine].set_visible(False)
371+
372+
# define tick positions
373+
ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00))
374+
ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25))
375+
376+
ax.tick_params(which='major', width=1.00, length=5)
377+
ax.tick_params(which='minor', width=0.75, length=2.5, labelsize=10)
378+
ax.set_xlim(0, 5)
379+
ax.set_ylim(0, 1)
380+
ax.text(0.0, 0.2, f'ax.xaxis.set_major_formatter({title})',
381+
transform=ax.transAxes, fontsize=14, fontname='Monospace',
382+
color='tab:blue')
383+
384+
ax.xaxis.set_major_formatter(formatter)
356385

357386

358387
Setting axes box aspect
@@ -450,9 +479,10 @@ and ``sum(x) > 1``, then an error is raised.
450479
ax[0, 1].pie(x, autopct='%1.2f%%', labels=label(x), normalize=True)
451480
ax[0, 1].set_title('normalize=True')
452481

453-
# For the purposes of keeping the documentation build warning-free, and
454-
# future proof for when the deprecation is made permanent, we pass
455-
# *normalize* here explicitly anyway.
482+
# This is supposed to show the 'old' behavior of not passing *normalize*
483+
# explicitly, but for the purposes of keeping the documentation build
484+
# warning-free, and future proof for when the deprecation is made
485+
# permanent, we pass *normalize* here explicitly anyway.
456486
ax[1, 0].pie(x, autopct='%1.2f%%', labels=label(x), normalize=False)
457487
ax[1, 0].set_title('normalize unspecified\nsum(x) < 1')
458488
ax[1, 1].pie(x * 10, autopct='%1.2f%%', labels=label(x * 10),

0 commit comments

Comments
 (0)