Creating a Transparent Plot

Hello,

Apologies for a basic question, but I am struggling with simply making a seismogram background transparent. I have written:

guio.plot(color=‘red’, starttime=start, endtime=end, transparent=‘True’, number_of_ticks=8)

but when I save the file as a .png and try to import into Illustrator, for example, the plot is not transparent, but rather white. I am hoping to extract waveforms with a transparent background but with a red trace to the waveform.

Thank you for the help,

Greg

Hi Greg,

you might have to save directly to a file to get the transparency. It is not super straightforward to achieve transparency in matplotlib. Also you used a string that says 'True' instead of the boolean value True so this might also be the problem.

Anyways, the following creates a transparent png on my PC:

>>> guio.plot(outfile="waveform.png", transparent=True)

If you want to import into Illustrator you will probably want to save the plot as a vector image. Saving it for example as a svg file should work. png is a rasterized format and thus not really suited for a vector program like illustrator.

Cheers!

Lion

Hi Greg,

You should pass the transparent arg to the savefig method, not the plot:

plt.savefig('demo.png', transparent=True)

Best regards from Brussels,

Thomas