EMF export doesn't work

Hall�chen!

I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
plot into an EMF file, I get

Traceback (most recent call last):
  File "./make_plots.py", line 23, in <module>
    figure.savefig(sample_name + "_pds.emf")
  File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 1419, in print_figure
    **kwargs)
  File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py", line 604, in print_emf
    self.figure.draw(renderer)
  File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in draw
    if self.frameon: self.patch.draw(renderer)
  File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in draw
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74, in draw_path
    raise NotImplementedError
NotImplementedError

Is this a bug or a mal-configuration? The Python code was

            figure = pyplot.figure()
            axes = figure.add_subplot(111)
            x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0, 1), unpack=True)
            axes.semilogy(x, y)
            figure.savefig("test.emf")

Tsch�,
Torsten.

···

--
Torsten Bronger, aquisgrana, europa vetus
                   Jabber ID: torsten.bronger@...2202...

Unfortunately, the EMF backend is no longer maintained. We had discussed removing it well over a year ago, and I actually thought it had been removed, but obviously it wasn't.

It needs someone to port it to the new backend API introduced in 0.98.x and to maintain that code. When quite some time ago, there really wasn't much interest in doing that. I would be happy to help someone with the details involved, but don't have the time myself at the moment.

Sorry for the confusion -- what do other developers think? Should we remove the backend and document the change, at least for the time being?

Mike

Torsten Bronger wrote:

···

Hall�chen!

I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
plot into an EMF file, I get

Traceback (most recent call last):
  File "./make_plots.py", line 23, in <module>
    figure.savefig(sample_name + "_pds.emf")
  File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 1419, in print_figure
    **kwargs)
  File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py", line 604, in print_emf
    self.figure.draw(renderer)
  File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in draw
    if self.frameon: self.patch.draw(renderer)
  File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in draw
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74, in draw_path
    raise NotImplementedError
NotImplementedError

Is this a bug or a mal-configuration? The Python code was

            figure = pyplot.figure()
            axes = figure.add_subplot(111)
            x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0, 1), unpack=True)
            axes.semilogy(x, y)
            figure.savefig("test.emf")

Tsch�,
Torsten.

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael Droettboom wrote:

Unfortunately, the EMF backend is no longer maintained. We had discussed removing it well over a year ago, and I actually thought it had been removed, but obviously it wasn't.

It needs someone to port it to the new backend API introduced in 0.98.x and to maintain that code. When quite some time ago, there really wasn't much interest in doing that. I would be happy to help someone with the details involved, but don't have the time myself at the moment.

Sorry for the confusion -- what do other developers think? Should we remove the backend and document the change, at least for the time being?

Mike,

Yes, like you I thought we had included it on the to-be-removed list, but evidently I remembered incorrectly.

Here is the history of the file:

10 months jdh2358 removed pre py2.4 compatability code and some other dead code
10 months mdboom Merged revisions 5106-5108 via svnmerge from
18 months mdboom Refactoring of FigureCanvas*.print_figure so that each backend does
19 months efiring Use pickle to cache entire fontManager instance.
21 months nnemec remove trailing spaces
2 years cmoad added rotation arg to draw_arc method everywhere it was missing
2 years jdh2358 added custom figure class hook
2 years jdh2358 fixed figimage bug
3 years jdh2358 added Aarre linestyle fix for emf backend
3 years dsdale added **kwargs to all backend_*.print_figure
3 years jdh2358 made the rc warnings a bit more readable
3 years jdh2358 added pyemf

I think it should be removed now. If someone comes forward with a strong commitment to update and maintain it, it can be reinstated easily--after that person has done the updating required to make it work in the trunk.

Eric

···

Mike

Torsten Bronger wrote:

Hallöchen!

I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
plot into an EMF file, I get

Traceback (most recent call last):
  File "./make_plots.py", line 23, in <module>
    figure.savefig(sample_name + "_pds.emf")
  File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 1419, in print_figure
    **kwargs)
  File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py", line 604, in print_emf
    self.figure.draw(renderer)
  File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in draw
    if self.frameon: self.patch.draw(renderer)
  File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in draw
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74, in draw_path
    raise NotImplementedError
NotImplementedError

Is this a bug or a mal-configuration? The Python code was

            figure = pyplot.figure()
            axes = figure.add_subplot(111)
            x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0, 1), unpack=True)
            axes.semilogy(x, y)
            figure.savefig("test.emf")

Tschö,
Torsten.

Hello there,

when I started with matplotlib I was really enthusiastic that I can throw
all those Excel, IDL, Matlab and whatever else I used until now overboard
and do everything from data processing to visualization in beloved Python.

Now, here at work I have to use a Windows PC and PowerPoint and graphics
just look best in PowerPoint if they are in EMF format.
Funny enough there seems to be no converter on the market to properly
convert any other vector format matplotlib can produce to EMF. Even the way
via Inkscape fails even with simple plots.

If I'm wrong about the converter, please tell me and bury EMF-support.
If not, what would you think would be the effort and the time needed to port
the emf-backend to the latest version of matplotlib? I might at least give
it a try.

Cheers,

Thomas

From: Michael Droettboom [mailto:mdroe@…86…]
Sent: Friday, March 20, 2009 5:38 PM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] EMF export doesn't work

Unfortunately, the EMF backend is no longer maintained. We had
discussed removing it well over a year ago, and I actually thought it
had been removed, but obviously it wasn't.

It needs someone to port it to the new backend API introduced in 0.98.x
and to maintain that code. When quite some time ago, there really
wasn't much interest in doing that. I would be happy to help someone
with the details involved, but don't have the time myself at the moment.

Sorry for the confusion -- what do other developers think? Should we
remove the backend and document the change, at least for the time being?

Mike

Torsten Bronger wrote:
> Hallöchen!
>
> I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
> plot into an EMF file, I get
>
> Traceback (most recent call last):
> File "./make_plots.py", line 23, in <module>
> figure.savefig(sample_name + "_pds.emf")
> File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in
savefig
> self.canvas.print_figure(*args, **kwargs)
> File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line

1419,

···

-----Original Message-----
in print_figure
> **kwargs)
> File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py",
line 604, in print_emf
> self.figure.draw(renderer)
> File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in
draw
> if self.frameon: self.patch.draw(renderer)
> File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in
draw
> renderer.draw_path(gc, tpath, affine, rgbFace)
> File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74,
in draw_path
> raise NotImplementedError
> NotImplementedError
>
> Is this a bug or a mal-configuration? The Python code was
>
> figure = pyplot.figure()
> axes = figure.add_subplot(111)
> x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0,
1), unpack=True)
> axes.semilogy(x, y)
> figure.savefig("test.emf")
>
> Tschö,
> Torsten.
>
>

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Thomas Pfaff wrote:

... EMF format. ... no converter on the market to properly
convert any other vector format matplotlib can produce to EMF. ...

hey thomas!

what about convert from imagemagick? "convert test.ps test.emf" gives
some output -- if this is indeed a correct emf file i cannot tell.

best,
sebastian.

Can you explain this?
Doesn't PDF work fine?

Alan Isaac

···

On 5/19/2009 4:50 AM Thomas Pfaff apparently wrote:

Now, here at work I have to use a Windows PC and PowerPoint and graphics
just look best in PowerPoint if they are in EMF format.

It would not be too much work to get a *mostly functional* backend
working, but to get a fully functional backend (eg including mathtext)
would be considerably harder. When Michael refactored the backends,
he dramatically simplified the number of methods that are required.
Starting with the template

  matplotlib download | SourceForge.net

and having the old backend_emf around to guide you

you could probably get something drawing lines and rectangles and text
in half a day's work.

JDH

···

On Tue, May 19, 2009 at 3:50 AM, Thomas Pfaff <yael@...361...> wrote:

Hello there,

when I started with matplotlib I was really enthusiastic that I can throw
all those Excel, IDL, Matlab and whatever else I used until now overboard
and do everything from data processing to visualization in beloved Python.

Now, here at work I have to use a Windows PC and PowerPoint and graphics
just look best in PowerPoint if they are in EMF format.
Funny enough there seems to be no converter on the market to properly
convert any other vector format matplotlib can produce to EMF. Even the way
via Inkscape fails even with simple plots.

If I'm wrong about the converter, please tell me and bury EMF-support.
If not, what would you think would be the effort and the time needed to port
the emf-backend to the latest version of matplotlib? I might at least give
it a try.

Hi Sebastian,

as far as I remember ImageMagick just puts a bitmap representation of the
image into the EMF-file (as does IrfanView and many others). What I want to
have is vectors, though.

Bests,

Thomas

···

-----Original Message-----
From: Sebastian Busch [mailto:webmaster@…2599…]
Sent: Tuesday, May 19, 2009 11:15 AM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] EMF export doesn't work

Thomas Pfaff wrote:
> ... EMF format. ... no converter on the market to properly
> convert any other vector format matplotlib can produce to EMF. ...

hey thomas!

what about convert from imagemagick? "convert test.ps test.emf" gives
some output -- if this is indeed a correct emf file i cannot tell.

best,
sebastian.

Thomas Pfaff wrote:

... ImageMagick just puts a bitmap representation of the
image into the EMF-file ... I want ... vectors, though.

hey thomas!

i see. perhaps xfig could then help you, it has an export to emf feature
(and can import ps files, see for example
Write appealing documents with LaTeX « thamnos.de ). and at least when
exporting pdf files, they are in a vector format.

best,
sebastian.

EMF support in OpenOffice is quite good (OOo uses emf internally, I
believe). You can import either SVG or PDF into OOo-Draw using the
respective OOo-extension and export as emf from there.

bc

···

On Tue, 2009-05-19 at 10:50 +0200, Thomas Pfaff wrote:

Hello there,

when I started with matplotlib I was really enthusiastic that I can throw
all those Excel, IDL, Matlab and whatever else I used until now overboard
and do everything from data processing to visualization in beloved Python.

Now, here at work I have to use a Windows PC and PowerPoint and graphics
just look best in PowerPoint if they are in EMF format.
Funny enough there seems to be no converter on the market to properly
convert any other vector format matplotlib can produce to EMF. Even the way
via Inkscape fails even with simple plots.

If I'm wrong about the converter, please tell me and bury EMF-support.
If not, what would you think would be the effort and the time needed to port
the emf-backend to the latest version of matplotlib? I might at least give
it a try.