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

Skip to content

Commit b0e668a

Browse files
kbroseMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #12203: Document legend best slowness
1 parent 2fe4080 commit b0e668a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/matplotlib/legend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
136136
corner of the legend in axes coordinates (in which case
137137
``bbox_to_anchor`` will be ignored).
138138
139+
The 'best' option can be quite slow for plots with large amounts
140+
of data. Your plotting speed may benefit from providing a specific
141+
location.
142+
139143
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
140144
Box that is used to position the legend in conjunction with *loc*.
141145
Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or

tutorials/introductory/usage.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,14 @@ def my_plotter(ax, data1, data2, param_dict):
760760
# plt.plot(y)
761761
# plt.show()
762762
#
763+
# Legends
764+
# -------
765+
#
766+
# The default legend behavior for axes attempts to find the location
767+
# that covers the fewest data points (`loc='best'`). This can be a
768+
# very expensive computation if there are lots of data points. In
769+
# this case, you may want to provide a specific location.
770+
#
763771
# Using the *fast* style
764772
# ----------------------
765773
#

0 commit comments

Comments
 (0)