SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Brent P. <bpe...@gm...> - 2007年07月29日 20:51:35
hi, with the simple script below, how can i make the image have a
transparent background instead of white? it's saving RGB, not RGBA.
thanks,
-brent
import matplotlib
matplotlib.use('Agg')
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
fig = Figure()
canvas = FigureCanvas(fig)
dpi = 64
fig.set_size_inches(256/dpi, 256/dpi)
#fig.figurePatch.set_alpha(1.)
fig.set_alpha(1.)
ax = fig.add_axes((0,0,1,1), axis_bgcolor=(1, 1, 1, 1.), alpha=1.,
frame_on=False, xticks=(), yticks=())
ax.plot([1,2,3])
fig.set_facecolor((1.,1.,1.,1.))
canvas.print_figure('t.png', dpi=dpi, facecolor=(1.,1.,1.,1.))
From: Brent P. <bpe...@gm...> - 2007年07月31日 20:02:47
sending again, doesnt seem to have gone through...
hi, with the simple script below, how can i make the image have a
transparent background instead of white? it's saving RGB, not RGBA.
thanks,
-brent
import matplotlib
matplotlib.use('Agg')
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
fig = Figure()
canvas = FigureCanvas(fig)
dpi = 64
fig.set_size_inches(256/dpi, 256/dpi)
#fig.figurePatch.set_alpha(1.)
fig.set_alpha(1.)
ax = fig.add_axes((0,0,1,1), axis_bgcolor=(1, 1, 1, 1.), alpha=1.,
frame_on=False, xticks=(), yticks=())
ax.plot([1,2,3])
fig.set_facecolor((1.,1.,1.,1.))
canvas.print_figure('t.png', dpi=dpi, facecolor=(1.,1.,1.,1.))
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /