From 99b0a31e5c76439e8bf196a126fc98b9b4299920 Mon Sep 17 00:00:00 2001 From: Kevin Rose Date: Fri, 21 Sep 2018 11:57:00 -0500 Subject: [PATCH 1/2] Mention legend slowness in performance section --- tutorials/introductory/usage.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tutorials/introductory/usage.py b/tutorials/introductory/usage.py index a1403d80b329..e877e8112a1f 100644 --- a/tutorials/introductory/usage.py +++ b/tutorials/introductory/usage.py @@ -760,6 +760,14 @@ def my_plotter(ax, data1, data2, param_dict): # plt.plot(y) # plt.show() # +# Legends +# ------- +# +# The default legend behavior for axes attempts to find the location +# that covers the fewest data points (`loc='best'`). This can be a +# very expensive computation if there are lots of data points. In +# this case, you may want to provide a specific location. +# # Using the *fast* style # ---------------------- # From e230deac26b341db76754353df8e6d0feacd5ef7 Mon Sep 17 00:00:00 2001 From: Kevin Rose Date: Fri, 21 Sep 2018 11:57:14 -0500 Subject: [PATCH 2/2] Mention legend slowness in legend docs --- lib/matplotlib/legend.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 6fe76fabd8e6..98d73f7b72e5 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -135,6 +135,10 @@ def _update_bbox_to_anchor(self, loc_in_canvas): corner of the legend in axes coordinates (in which case ``bbox_to_anchor`` will be ignored). + The 'best' option can be quite slow for plots with large amounts + of data. Your plotting speed may benefit from providing a specific + location. + bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats Box that is used to position the legend in conjunction with *loc*. Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or