Skip to content

Default legend location 'best' is extremely slow #8108

@MaartenBaert

Description

@MaartenBaert

Matplotlib 2.0.0 seems to have changed the default legend location from "upper right" to "best" (although the documentation doesn't say this). I have noticed that this results in a severe performance penalty: several plots which would normally render in a fraction of a second now need 5-10 seconds. To make things worse, the legend location is recalculated whenever the plot is moved or zoomed. The sharex/sharey functionality which I use quite a lot makes this even slower, since all subplots are moved or zoomed simultaneously.

Code for reproduction

from pylab import *

x = linspace(0, 100, 100000)

close("all")
figure("Test", figsize=(12, 8))
for j in range(9):
	if j == 0:
		ax = subplot(3, 3, 1)
	else:
		subplot(3, 3, j + 1, sharex=ax, sharey=ax)
	for i in range(8):
		plot(x, sin(x + i * 0.5), color=cm.magma(i/8), label="test")
	legend(fontsize="small")

tight_layout()
show()

Matplotlib version

  • Matplotlib 2.0.0 (installed with pip)
  • Python 3.6.0 (compiled from source)
  • Platform: Linux (CentOS 6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    PerformancekeepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy