Skip to content
Advertisement

Matplotlib pickle error “TypeError: cannot pickle ‘kiwisolver.Solver’ object”

In my project I’m trying to embed the same matplotlib figure in two places and seem to need to make a copy, as I’m using blitting on the original, and embedding a figure in two places & closing one causes a crash issue w/ blitting an imshow in matplotlib (but not scatterplots). In order to do this I’m using pickle on the matplotlib figure, but I’m getting the error stated in the title. The function where I’m doing the embedding is below, but the first line where dumps/loads from pickle is erroring only my figure w/ scatterplots.

JavaScript

I store my different figures in a list and embed the one that is the current “focus” w/ the embed function above. And for reference here is my (messy) figure that is the one that errors.

JavaScript

If anyone knows either how to fix the pickling issue w/ the scatterplots, or a different way to work around the total crash with an imshow, either would achieve what I’m trying to do.

Advertisement

Answer

Turns out the issue was setting constrained_layout. Setting it to false allows figure to be successfully pickled without any errors.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement