I have a Qt4 application with dynamic embedded matplotlib plotting.
The application allows the user to add and remove lines from the plot.
This all works well, but I have found that updating the legend is
causing a memory leak. What is the proper way to update the legend in
an animated/dynamic context? The attached stand alone example
exemplifies the problem. On my system, with matplotlib.__version__
'1.0.0' compiled from SVN, the memory slowly increases as the script
runs. This does not happen if I remove the ax.legend() call. The del
ax.legend_ line seems to have no effect. I tried finding the artists
associated with the legend What's the appropriate way to update the
legend to avoid this behavior? I just found ax.legend_.remove() but it
legendtest.py (443 Bytes)