Skip to content

Commit 84a0313

Browse files
committed
add api change note
1 parent 43e9c74 commit 84a0313

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Change of the (default) legend handler for Line2D instances
2+
-----------------------------------------------------------
3+
4+
The default legend handler for Line2D instances (`.HandlerLine2D`) now
5+
consistently exposes all the attributes and methods related to the line
6+
marker (:ghissue:`11358`). This makes easy to change the marker features
7+
after instantiating a legend.
8+
9+
.. code::
10+
11+
import matplotlib.pyplot as plt
12+
13+
fig, ax = plt.subplots()
14+
15+
ax.plot([1, 3, 2], marker="s", label="Line", color="pink", mec="red", ms=8)
16+
leg = ax.legend()
17+
18+
leg.legendHandles[0].set_color("lightgray")
19+
leg.legendHandles[0].set_mec("black") # marker edge color
20+
21+
The former legend handler for Line2D objects has been renamed
22+
`.HandlerLine2DCompound`. To revert to the behavior that was used before
23+
Matplotlib 3, one can use
24+
25+
.. code::
26+
27+
import matplotlib.legend as mlegend
28+
from matplotlib.legend_handler import HandlerLine2DCompound
29+
from matplotlib.lines import Line2D
30+
31+
mlegend.Legend.update_default_handler_map({Line2D: HandlerLine2DCompound()})
32+

0 commit comments

Comments
 (0)