Skip to content

Commit 5111092

Browse files
committed
MNT: Update internal usages of privatized Formatter attributes in ticker.py
1 parent 310092b commit 5111092

23 files changed

Lines changed: 265 additions & 111 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
persist-credentials: false
3535

3636
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@38697555549f1db7851b81482ff19f1fa5c4fedc # v4.34.1
37+
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
3838
with:
3939
languages: ${{ matrix.language }}
4040

@@ -45,4 +45,4 @@ jobs:
4545
pip install --user -v .
4646
4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@38697555549f1db7851b81482ff19f1fa5c4fedc # v4.34.1
48+
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ jobs:
395395
fi
396396
- name: Upload code coverage
397397
if: ${{ !cancelled() && github.event_name != 'schedule' }}
398-
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
398+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
399399
with:
400400
name: "${{ matrix.python-version }} ${{ matrix.os }} ${{ matrix.name-suffix }}"
401401
token: ${{ secrets.CODECOV_TOKEN }}

doc/api/next_api_changes/deprecations/31416-TH.rst

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

doc/api/ticker_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.. automodule:: matplotlib.ticker
66
:members:
77
:undoc-members:
8+
:special-members: __call__
89
:show-inheritance:
910

1011

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Partial ``figsize`` specification at figure creation
2+
----------------------------------------------------
3+
4+
Figure creation now accepts a single ``None`` in ``figsize``.
5+
Passing ``(None, h)`` uses the default width from :rc:`figure.figsize`, and
6+
passing ``(w, None)`` uses the default height.
7+
Passing ``(None, None)`` is invalid and raises a `ValueError`.
8+
9+
For example::
10+
11+
import matplotlib.pyplot as plt
12+
fig = plt.figure(figsize=(None, 4))

lib/matplotlib/artist.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,12 @@ def remove(self):
255255
# clear stale callback
256256
self.stale_callback = None
257257
_ax_flag = False
258-
if hasattr(self, 'axes') and self.axes:
258+
ax = getattr(self, 'axes', None)
259+
mouseover_set = getattr(ax, '_mouseover_set', None)
260+
if mouseover_set is not None:
259261
# remove from the mouse hit list
260-
self.axes._mouseover_set.discard(self)
261-
self.axes.stale = True
262+
mouseover_set.discard(self)
263+
ax.stale = True
262264
self.axes = None # decouple the artist from the Axes
263265
_ax_flag = True
264266

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ def secondary_xaxis(self, location, functions=None, *, transform=None, **kwargs)
556556
"""
557557
Add a second x-axis to this `~.axes.Axes`.
558558
559-
For example if we want to have a second scale for the data plotted on
560-
the xaxis.
559+
This axis is typically used to display a second x-scale for the data
560+
plotted on the Axes.
561561
562562
%(_secax_docstring)s
563563
@@ -610,8 +610,8 @@ def secondary_yaxis(self, location, functions=None, *, transform=None, **kwargs)
610610
"""
611611
Add a second y-axis to this `~.axes.Axes`.
612612
613-
For example if we want to have a second scale for the data plotted on
614-
the yaxis.
613+
This axis is typically used to display a second y-scale for the data
614+
plotted on the Axes.
615615
616616
%(_secax_docstring)s
617617

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ def set_color(self, color):
329329
Returns
330330
-------
331331
ax : axes._secondary_axes.SecondaryAxis
332+
The returned Axes is overlaid on top of the original Axes and all
333+
components except for the complementary axis are hidden. You may modify
334+
the complementary axis, e.g. by setting ticks or an axis label. However,
335+
it is not designed to hold data, so that you should not call any
336+
plotting methods on it.
332337
333338
Other Parameters
334339
----------------

lib/matplotlib/collections.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,15 @@ def legend_elements(self, prop="colors", num="auto",
12711271
"alpha": self.get_alpha(),
12721272
**kwargs}
12731273

1274-
for val, lab in zip(values, label_values):
1274+
# Pre-format all labels
1275+
# TODO: check whether we can switch to
1276+
# formatted_labels = fmt.format_ticks(label_values)
1277+
# There are subtle differences for some formatters as that passes the
1278+
# indices to __call__ as well.
1279+
fmt.set_locs(label_values)
1280+
formatted_labels = [fmt(lab) for lab in label_values]
1281+
1282+
for val, formatted in zip(values, formatted_labels):
12751283
if prop == "colors":
12761284
color = self.cmap(self.norm(val))
12771285
elif prop == "sizes":
@@ -1281,10 +1289,7 @@ def legend_elements(self, prop="colors", num="auto",
12811289
h = mlines.Line2D([0], [0], ls="", color=color, ms=size,
12821290
marker=self.get_paths()[0], **kw)
12831291
handles.append(h)
1284-
if hasattr(fmt, "set_locs"):
1285-
fmt.set_locs(label_values)
1286-
l = fmt(lab)
1287-
labels.append(l)
1292+
labels.append(formatted)
12881293

12891294
return handles, labels
12901295

lib/matplotlib/contour.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ def clabel(self, levels=None, *,
143143
-------
144144
labels
145145
A list of `.Text` instances for the labels.
146+
147+
Note: The returned Text instances should not be individually
148+
removed or have their geometry modified, e.g. by changing text or font size.
149+
If you need such a modification, remove the entire
150+
`.ContourSet` and recreate it.
146151
"""
147152

148153
if self.filled:
@@ -515,7 +520,14 @@ def labels(self, inline, inline_spacing):
515520
def remove(self):
516521
super().remove()
517522
for text in self.labelTexts:
518-
text.remove()
523+
try:
524+
text.remove()
525+
except ValueError:
526+
_api.warn_external(
527+
"Some labels were manually removed before the ContourSet. "
528+
"To remove labels cleanly, remove the entire ContourSet "
529+
"and recreate it.")
530+
self.labelTexts.clear()
519531

520532

521533
def _find_closest_point_on_path(xys, p):

0 commit comments

Comments
 (0)