multiple savefig() –> Error: alloc: invalid block


I could not have multiple savefig() ‘s with different styles.

I wrote a sample code on stackoverflow.

I got some help somebody posted his results (as a picture). If I copy-paste his code, and run it I got an “alloc: invalid block” error. And the following 2 pictures:



The color of labels and legendtext is still white..
Is it possible that it is a bug?

My system: Win7 + Python3.4 + MatPlotlib 1.4.2

Thx for helping

Author: Fantashit

1 thought on “multiple savefig() –> Error: alloc: invalid block

  1. I had the same crash (matplotlib alloc: invalid block) in a similar code:

    def save_result_figure(image, curve, fname):
        fig, ax = plt.subplots(1, 1)
        ax.imshow(image, cmap='gray')
        ax.plot(curve.x, curve.y, linewidth=2, color='r')

    This function has been called multiple times from the unit tests.

    I have added this line to the end of my function:


    And this error doesn’t occur anymore! 🙂

Comments are closed.