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

Skip to content

Commit 6291430

Browse files
committed
Fix broken example, add to api_changes, tweak error message.
1 parent dbe6f35 commit 6291430

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

doc/api/api_changes_3.3/behaviour.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ did nothing, when passed an unsupported value. It now raises a ``ValueError``.
3737
`.pyplot.tick_params`) used to accept any value for ``which`` and silently
3838
did nothing, when passed an unsupported value. It now raises a ``ValueError``.
3939

40+
``Axis.set_ticklabels()`` must match ``FixedLocator.locs``
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
If an axis is using a `.tickers.FixedLocator`, typically set by a call to
43+
`.Axis.set_ticks`, then the number of ticklabels supplied must match the
44+
number of locations available (``FixedFormattor.locs``). If not, a
45+
``ValueError`` is raised.
46+
4047
``backend_pgf.LatexManager.latex``
4148
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4249
``backend_pgf.LatexManager.latex`` is now created with ``encoding="utf-8"``, so

examples/images_contours_and_fields/image_annotated_heatmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
289289
# `matplotlib.ticker.FuncFormatter`.
290290

291291
corr_matrix = np.corrcoef(np.random.rand(6, 5))
292-
im, _ = heatmap(corr_matrix, vegetables, vegetables, ax=ax4,
292+
im, _ = heatmap(corr_matrix, vegetables, farmers, ax=ax4,
293293
cmap="PuOr", vmin=-1, vmax=1,
294294
cbarlabel="correlation coeff.")
295295

lib/matplotlib/axis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,8 @@ def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
16381638
if len(locator.locs) != len(ticklabels):
16391639
raise ValueError(
16401640
"The number of FixedLocator locations"
1641-
f" ({len(locator.locs)}) does not match"
1641+
f" ({len(locator.locs)}), usually from a call to"
1642+
" set_ticks, does not match"
16421643
f" the number of ticklabels ({len(ticklabels)}).")
16431644
tickd = {loc: lab for loc, lab in zip(locator.locs, ticklabels)}
16441645
func = functools.partial(self._format_with_dict, tickd)

0 commit comments

Comments
 (0)