Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0e668a

Browse filesBrowse files
kbroseMeeseeksDev[bot]
authored andcommitted
Backport PR #12203: Document legend best slowness
1 parent 2fe4080 commit b0e668a
Copy full SHA for b0e668a

File tree

Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed

‎lib/matplotlib/legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend.py
+4Lines 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

Copy file name to clipboardExpand all lines: tutorials/introductory/usage.py
+8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.