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

Hi,

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

I wrote a sample code on stackoverflow.

http://stackoverflow.com/questions/28024050/multiple-savefig-s-with-different-styles/28024420?noredirect=1#comment44438695_28024420

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:

result_dark

result_white

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')
        fig.savefig(fname)

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

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

    plt.close()

    And this error doesn’t occur anymore! 🙂

Comments are closed.