New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plotting gets slower as more plots are created #3
Comments
I should mention, this |
@caseygrun Thank you for your pointing, and I'm sorry that my dirty code wastes your valuable time... However, I re-implemented the |
In any case, Patchworklib is still under development and the number of users is probably still small. |
On the contrary, your library has saved me lots of time by providing a solution to a problem I would have otherwise had to solve some other way. So thanks for that! And thanks for the quick patch, I will try it out. Just a few more thoughts after pondering this last night...
I wonder if it is inevitable though. It's certainly the case that the more But I'll have to test out your new version first, since if I understand correctly, you basically remove all the axes except the ones you need, then periodically add axes back when it's time to |
First, thanks for making this clearly much-needed package. It's kind of crazy this problem has not been solved in the MPL ecosystem before.
I have noticed that, with each
Brick
created and plotted, patchwork gets slower. Note, the problem is not that larger collections ofBrick
s are slower, it's that with eachBrick
created, everyBrick
plotted is slower:This is just a toy example, the problem gets way worse for bigger figures.
I did some line profiling and discovered the slow part is
ax.savefig
. I learned that internally,patchworklib
is adding axes for each plot to a single giant sharedmatplotlib.figure.Figure
, which grows axes with each Brick added:As I understand, to
savefig
on a givenBrick
, you deep-copy that figure usingdill
, then delete the axes you don't need. As this über-figure grows, the time spent dumping and loading inBrick.savefig
increases.As a hack, I have been running this function periodically; nuking that big figure speeds things back up. There is still a lot of overhead in the pickling/unpickling, but at least it doesn't get worse and worse.
I'm hoping we can figure out a better solution for this; unfortunately, this would seem to require reworking the internals of the library. Any ideas?
The text was updated successfully, but these errors were encountered: