|
From: Brian B. <bb...@br...> - 2007-07-27 01:27:39
|
On Jul 26, 2007, at Jul 26:4:49 PM, Jouni K. Sepp=E4nen wrote:
> Brian Blais <bb...@br...> writes:
>
>> and it works with pylab. But, if I use matplotlib.Figure directly in
>> an app, and then call:
>> myfig.savefig('blah.pdf') it saves it as 'blah.pdf.jpg', a jpeg =20
>> file.
>
> Sounds like you are using a backend other than the pdf one. Can you
> write up a complete example of code that behaves like you describe?
>
This is the smallest example I can write. I am embedding the figure =20
in a wx window. In this test case, I print (successfully) a PNG and =20
EPS, but the PDF doesn't work (gets a .jpg attached to the end).
bb
--=20
Brian Blais
bb...@br...
http://web.bryant.edu/~bblais
#!/usr/bin/env python
import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWx as =20
FigureCanvas
from matplotlib.figure import Figure
class MainWindow(wx.Frame):
""" We simply derive a new class of Frame. """
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=3D(400,400))
fig =3D Figure()
canvas =3D FigureCanvas(self,-1, fig)
ax=3Dfig.add_subplot(111)
ax.plot([1,2,3,4],'o')
canvas.draw()
self.Show(True)
fig.savefig('blah.eps')
fig.savefig('blah.png')
fig.savefig('blah.pdf')
app =3D wx.PySimpleApp()
frame=3DMainWindow(None, wx.ID_ANY, 'Test')
app.MainLoop()
|