8000 Default legend location 'best' is extremely slow · Issue #8108 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Default legend location 'best' is extremely slow #8108
Open
@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

      0