best format for MS word?

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

Shixin Zeng wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word?

You can try PyEMF. I don't know its status -- it might need some TLC.
http://pyemf.sourceforge.net/

How do I utilize pyEmf? AFAIK, it's used by the old emf backend in
matplotlib, which is not maintained or functional any more.

Best Regards

Shixin Zeng

···

On Tue, Sep 1, 2009 at 8:14 PM, Andrew Straw<strawman@...106...> wrote:

Shixin Zeng wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word?

You can try PyEMF. I don't know its status -- it might need some TLC.
http://pyemf.sourceforge.net/

Shixin Zeng wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

Have you tried brute-force? Make a very high-resolution png (use a high dpi setting in savefig), and import that?

Eric

···

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Yes, the DPI i'm using is 300, and I tried to change it to 600, or
1200, but I can't see much difference.

Best Regards

Shixin Zeng

···

On Tue, Sep 1, 2009 at 9:28 PM, Eric Firing<efiring@...202...> wrote:

Shixin Zeng wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

Have you tried brute-force? Make a very high-resolution png (use a high
dpi setting in savefig), and import that?

Eric

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day trial. Simplify your report design, integration and deployment - and
focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

OK,

I'm attaching a file that converts svg to emf, which is based on
librsvg and cairo.

I've spent the all night working on this, but the result is still not
satisfying. The converted emf file is even worse than the png file
produced from matplotlib. I'm not sure if it's because I did something
wrong or it's because of the limitation of this method itself. I'm
posting here in hope of some one with more knowledge would enlighten
me. Thanks.

To build the problem, you need to download librsvg and it's dependency
from Index of /binaries/win32/

Best Regards

Shixin Zeng

main.c (2.84 KB)

···

On Tue, Sep 1, 2009 at 6:43 PM, Shixin Zeng<zeng.shixin@...287...> wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

I had similar problem
try hi-res png images at 300dpi w/o transparency (ms cannot handle
transp. png correctly).
ms word shows png little blury, but after printing (to PDF for
example) images are sharp as knife

2009/9/2 Shixin Zeng <zeng.shixin@...287...>:

···

OK,

I'm attaching a file that converts svg to emf, which is based on
librsvg and cairo.

I've spent the all night working on this, but the result is still not
satisfying. The converted emf file is even worse than the png file
produced from matplotlib. I'm not sure if it's because I did something
wrong or it's because of the limitation of this method itself. I'm
posting here in hope of some one with more knowledge would enlighten
me. Thanks.

To build the problem, you need to download librsvg and it's dependency
from Index of /binaries/win32/

Best Regards

Shixin Zeng

On Tue, Sep 1, 2009 at 6:43 PM, Shixin Zeng<zeng.shixin@...287...> wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I haven't tried it myself, but this converter may do the trick. If it works, can you report back? I'd be interested to know:
<http://sk1project.org/modules.php?name=Products&product=uniconvertor&gt;

Gary R.

Shixin Zeng wrote:

···

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

MS simply doesn't lay well with open vector formats, I think PNG with the right DPI, etc is still probably your best bet.

Shixin Zeng wrote:

I'm attaching a file that converts svg to emf, which is based on
librsvg and cairo.

I've spent the all night working on this, but the result is still not
satisfying. The converted emf file is even worse than the png file
produced from matplotlib. I'm not sure if it's because I did something
wrong or it's because of the limitation of this method itself.

I suspect you are getting a raster embedded in the emf, rather than proper vector graphics, but that's just a guess. This message is a couple years old, but does seem to indicate the vector emf is not supported (or wasn't then):

http://lists.cairographics.org/archives/cairo/2007-February/009805.html

However, if Cairo does support verctor emf, than you might be able to use the MPL Cairo back-end, rather than trying to go to SVG->emf.

good luck!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

MS simply doesn't lay well with open vector formats, I think PNG with
the right DPI, etc is still probably your best bet.

Yes, I think I have to stick to this option

Shixin Zeng wrote:

I'm attaching a file that converts svg to emf, which is based on
librsvg and cairo.

I've spent the all night working on this, but the result is still not
satisfying. The converted emf file is even worse than the png file
produced from matplotlib. I'm not sure if it's because I did something
wrong or it's because of the limitation of this method itself.

I suspect you are getting a raster embedded in the emf, rather than
proper vector graphics, but that's just a guess. This message is a
couple years old, but does seem to indicate the vector emf is not
supported (or wasn't then):

http://lists.cairographics.org/archives/cairo/2007-February/009805.html

However, if Cairo does support verctor emf, than you might be able to
use the MPL Cairo back-end, rather than trying to go to SVG->emf.

I looked at the cairo backend of MPL, it doesn't support EMF, it has
only pdf, ps, svg, svgz outputs.

···

On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barker<Chris.Barker@...259...> wrote:

good luck!

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

No, it doesn't work for me. Either it can't convert, or the quality is
pretty low, there are some black blocks in the converted plot.

Best Regards

Shixin Zeng

···

On Wed, Sep 2, 2009 at 8:30 AM, Gary Ruben<gruben@...636...> wrote:

I haven't tried it myself, but this converter may do the trick. If it works,
can you report back? I'd be interested to know:
<http://sk1project.org/modules.php?name=Products&product=uniconvertor&gt;

Gary R.

Shixin Zeng wrote:

Hi,

Could someone tell me what's the best format that matplotlib can
produce for insertion to MS word? I'm working on a paper using MS
word. I used matplotlib to produce the pictures in "png' format, but
my professor doesn't satisfy with the quality of the pictures, he asks
me to do it in "emf" format, but I can't get an "emf" output from
matplotlib. While other vector formats that are supported by
matplotlib are not supported by MS word. I have worked days on
producing this pictures, I don't want to abandon them just because
they can't be imported to MS word. I really like to produce my
pictures by using matplotlib, but I can't really throw away MS word. I
also tried pstoedit to try to convert to emf from the ps, but it
doesn't work on my system due to some weired missing procedure entry
points in imagick dll.

I'm kinda in a hurry, any help would be greatly appreciated.

Best Regards

Shixin Zeng

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day trial. Simplify your report design, integration and deployment - and
focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I agree; in my experience, a bitmap such as PNG at about 600 dpi is the most
robust, straightforward method for getting a reasonable image in Word on both
screen and paper. By the way, I seem to recall noticing differences across
versions of Word in the way they perform smoothing, anti-aliasing, or
interpolation on displayed bitmaps. I can't remember which version(s) blurred
them excessively, but Word 2003 is satisfactory to me.

In case you still want to go for vector rendering, I'll mention that I have
had some success with tools to convert to EMF. One way to go is pstoedit, but
you already mentioned having difficulty getting it working. (Anyway, you
might have needed the shareware EMF driver
[http://www.helga-glunz.homepage.t-online.de/plugins/\], depending on your
quality standards.) Another possibility is Adobe Illustrator; it can read EPS
and export to EMF, and I've been pleased with the fidelity. I've found that
it doesn't always identify the fonts correctly, but I've worked around that
with Illustrator's font replacement command. A third approach (untested by
me) is to install a virtual EMF printer, such as
http://emfprinter.sourceforge.net/ or
http://www.mabuse.de/tech-vprinter.mhtml. Save your figure as a PDF, open in
a PDF application, and use the print dialog with your EMF printer to write an
EMF file. (It might also work to save as EPS, open in GSView, then print.)
You might end up with a bounding box as large as your paper size, but in Word
you could manually crop to the actual image. With any of these approaches, I
recommend watching for defects. I've found that such conversions often get
something wrong--the coordinates of the primitives get rounded (to the nearest
1/72 inch, I'm guessing), or you get hairlines instead of the line width you
wanted, or the image size is wrong.

If the screen display is less important than a hard copy or a PDF version of
your document, the following might work for you: Save your figure as EPS and
place that in your Word document. Older versions of Word will display a box
placeholder, while newer versions of Word contain a simple PostScript
processor and will display a bitmap that bears a passing resemblance to your
figure. Regardless, the EPS is still there and should be delivered to PS
devices, such as a physical printer or a virtual printer like PDFCreator. If
you want to get really fancy, you can embed a high-resolution bitmap into the
EPS file as a preview and get a better on-screen version, too, although with
newer Word versions you might need to defeat the built-in PS engine for your
preview to prevail.

···

On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barker<Chris.Barker@...259...> wrote:
> MS simply doesn't lay well with open vector formats, I think PNG with
> the right DPI, etc is still probably your best bet.
>
Yes, I think I have to stick to this option

Can't word handle eps files? In the WYSIWYG it will show the embedded preview as far as I recall, so the image will seem empty if their is no preview embedded or blurry if the preview is blurry. For printing however (including to pdf) it uses the vector version. Of course, eps can't handle transparency.

Stan West wrote:

···

On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barker<Chris.Barker@...259...> >> > wrote:
  

MS simply doesn't lay well with open vector formats, I think PNG with the right DPI, etc is still probably your best bet.

Yes, I think I have to stick to this option
    
I agree; in my experience, a bitmap such as PNG at about 600 dpi is the most
robust, straightforward method for getting a reasonable image in Word on both
screen and paper. By the way, I seem to recall noticing differences across
versions of Word in the way they perform smoothing, anti-aliasing, or
interpolation on displayed bitmaps. I can't remember which version(s) blurred
them excessively, but Word 2003 is satisfactory to me.

In case you still want to go for vector rendering, I'll mention that I have
had some success with tools to convert to EMF. One way to go is pstoedit, but
you already mentioned having difficulty getting it working. (Anyway, you
might have needed the shareware EMF driver
[http://www.helga-glunz.homepage.t-online.de/plugins/\], depending on your
quality standards.) Another possibility is Adobe Illustrator; it can read EPS
and export to EMF, and I've been pleased with the fidelity. I've found that
it doesn't always identify the fonts correctly, but I've worked around that
with Illustrator's font replacement command. A third approach (untested by
me) is to install a virtual EMF printer, such as
http://emfprinter.sourceforge.net/ or
http://www.mabuse.de/tech-vprinter.mhtml. Save your figure as a PDF, open in
a PDF application, and use the print dialog with your EMF printer to write an
EMF file. (It might also work to save as EPS, open in GSView, then print.)
You might end up with a bounding box as large as your paper size, but in Word
you could manually crop to the actual image. With any of these approaches, I
recommend watching for defects. I've found that such conversions often get
something wrong--the coordinates of the primitives get rounded (to the nearest
1/72 inch, I'm guessing), or you get hairlines instead of the line width you
wanted, or the image size is wrong.

If the screen display is less important than a hard copy or a PDF version of
your document, the following might work for you: Save your figure as EPS and
place that in your Word document. Older versions of Word will display a box
placeholder, while newer versions of Word contain a simple PostScript
processor and will display a bitmap that bears a passing resemblance to your
figure. Regardless, the EPS is still there and should be delivered to PS
devices, such as a physical printer or a virtual printer like PDFCreator. If
you want to get really fancy, you can embed a high-resolution bitmap into the
EPS file as a preview and get a better on-screen version, too, although with
newer Word versions you might need to defeat the built-in PS engine for your
preview to prevail.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks for your input. As I've stated before, I have lots of pictures
in the paper, I need them to have same style, including the
size/margins. So printing to a EMF file on a whole page and cropping
is not acceptable to me, it's hard to control the size/margins/scaling
factor.

While for embeding eps files in word, I've just tried that. MS word
2007 seems to have some problem on this. See the attached eps file
produced from matplotlib. In MS word 2007, the labels and titles of
axes are gone, even on the printed version of the word file. It's
there when I view/print it with gsview.

rta1.eps (40.9 KB)

···

On Wed, Sep 2, 2009 at 1:50 PM, Stan West<stan.west@...706...> wrote:

On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barker<Chris.Barker@...2155.....> > wrote:
> MS simply doesn't lay well with open vector formats, I think PNG with
> the right DPI, etc is still probably your best bet.
>
Yes, I think I have to stick to this option

I agree; in my experience, a bitmap such as PNG at about 600 dpi is the most
robust, straightforward method for getting a reasonable image in Word on both
screen and paper. By the way, I seem to recall noticing differences across
versions of Word in the way they perform smoothing, anti-aliasing, or
interpolation on displayed bitmaps. I can't remember which version(s) blurred
them excessively, but Word 2003 is satisfactory to me.

In case you still want to go for vector rendering, I'll mention that I have
had some success with tools to convert to EMF. One way to go is pstoedit, but
you already mentioned having difficulty getting it working. (Anyway, you
might have needed the shareware EMF driver
[http://www.helga-glunz.homepage.t-online.de/plugins/\], depending on your
quality standards.) Another possibility is Adobe Illustrator; it can read EPS
and export to EMF, and I've been pleased with the fidelity. I've found that
it doesn't always identify the fonts correctly, but I've worked around that
with Illustrator's font replacement command. A third approach (untested by
me) is to install a virtual EMF printer, such as
http://emfprinter.sourceforge.net/ or
http://www.mabuse.de/tech-vprinter.mhtml. Save your figure as a PDF, open in
a PDF application, and use the print dialog with your EMF printer to write an
EMF file. (It might also work to save as EPS, open in GSView, then print.)
You might end up with a bounding box as large as your paper size, but in Word
you could manually crop to the actual image. With any of these approaches, I
recommend watching for defects. I've found that such conversions often get
something wrong--the coordinates of the primitives get rounded (to the nearest
1/72 inch, I'm guessing), or you get hairlines instead of the line width you
wanted, or the image size is wrong.

If the screen display is less important than a hard copy or a PDF version of
your document, the following might work for you: Save your figure as EPS and
place that in your Word document. Older versions of Word will display a box
placeholder, while newer versions of Word contain a simple PostScript
processor and will display a bitmap that bears a passing resemblance to your
figure. Regardless, the EPS is still there and should be delivered to PS
devices, such as a physical printer or a virtual printer like PDFCreator. If
you want to get really fancy, you can embed a high-resolution bitmap into the
EPS file as a preview and get a better on-screen version, too, although with
newer Word versions you might need to defeat the built-in PS engine for your
preview to prevail.

--
Bese regards

Shixin Zeng

Yes, that was my experience as well, and not just with Word.
I think MS products are not playing nicely with EPS, but you
might try cleaning it with eps2eps to see if that helps.

Alan Isaac

···

On 9/2/2009 4:11 PM Shixin Zeng apparently wrote:

While for embeding eps files in word, I've just tried that. MS word
2007 seems to have some problem on this. See the attached eps file
produced from matplotlib. In MS word 2007, the labels and titles of
axes are gone, even on the printed version of the word file. It's
there when I view/print it with gsview.

I don't have Word 2007, but I imported your file into Word 2003 and saw that
the titles and labels were missing. I would blame that on shortcomings of the
Word PS engine. When I printed to a non-PostScript printer, the titles and
labels were missing as in your test; that doesn't surprise me, because the
Word PS engine would be used to render for a non-PS printer. However, when I
printed to PostScript devices (the Adobe PDF driver and the PDFCreator
driver), the titles and text were present; Word shouldn't invoke its PS engine
when the printer understands PS. Is there any chance that you were using a
non-PS printer, or that your printer has two or more modes (like the
Hewlett-Packard models that automatically switch between PCL and PS) and you
were not using a PS driver? How about testing with PDFCreator?

···

-----Original Message-----
From: Shixin Zeng [mailto:zeng.shixin@…287…]
Sent: Wednesday, September 02, 2009 16:11

While for embeding eps files in word, I've just tried that. MS word
2007 seems to have some problem on this. See the attached eps
file produced from matplotlib. In MS word 2007, the labels
and titles of axes are gone, even on the printed version of
the word file. It's there when I view/print it with gsview.