SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(16)
2
(31)
3
(17)
4
(18)
5
(7)
6
(5)
7
(16)
8
(9)
9
(19)
10
(18)
11
(17)
12
(7)
13
(6)
14
(15)
15
(16)
16
(15)
17
(19)
18
(27)
19
(10)
20
(5)
21
(5)
22
(19)
23
(7)
24
(11)
25
(19)
26
(1)
27
(36)
28
(37)
29
(28)
30
(36)



Showing results of 31

1 2 > >> (Page 1 of 2)
From: Richard M. <rg...@as...> - 2009年09月02日 23:37:19
Hello,
I want to display some data as an image and also as a contour.
I have been looking at imshow and pcolor and find that contour
and imshow are behaving differently than pcolor. In the example below I
have a 5x5 image. pshow displays the pixels but imshow and contour shows
resampling artifacts since they resample offset by 0.5pixels.
The advantage of imshow is that the pixels are square which is what I
want. I also want to use contour which also seems to show the same
type of resampling as imshow.
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
image = np.random.rand(5,5)
plt.figure()
plt.pcolor(image)
plt.title('pcolor defaults')
plt.figure()
plt.imshow(image, origin='lower')
plt.title('imshow defaults with origin=lower')
plt.show()
Is there a method to force imshow to not resample the image
It is not obvius to me from reading the help for imshow and pcolor.
Thanks, richard
-------------------------------------------------------------------
 Dr. Richard G. McMahon | Phone (office) 44-(0)-1223-337519
 University of Cambridge | (switchboard) 1223-337548
 Institute of Astronomy | (secretary) 1223-337516
 Madingley Rd | FAX 1223-337523
 Cambridge, CB3 OHA, UK. | mobile 7885-409019
 Office: Hoyle 18 | home 1223-359770
-------------------------------------------------------------------
 email: rg...@as... | WWW: http://www.ast.cam.ac.uk/~rgm
 ric...@gm... | skype: richardgmcmahon
-------------------------------------------------------------------
From: Shixin Z. <zen...@gm...> - 2009年09月02日 20:11:40
Attachments: rta1.eps
On Wed, Sep 2, 2009 at 1:50 PM, Stan West<sta...@nr...> wrote:
>> On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barker<Chr...@no...>
> 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.
>
>
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.
--
Bese regards
Shixin Zeng
From: Jae-Joon L. <lee...@gm...> - 2009年09月02日 19:28:40
On Wed, Sep 2, 2009 at 11:41 AM, Sebastian Rhode<seb...@go...> wrote:
> So I already figure out how to delete the last drawn line, but this is not a
> very good solution. What I actually would need, is a selection which line &
> legend the users whats to remove from the graph (perfect would be
> interactivly directly from the graph). But so far, I could not figure this
> out. Has anyone a good ides how to achieve this?
All the matplotlib plot commands return artists created by that plot
command. Unless you want those permanently removed from the current
plot, it is suffice to just make them invisible
(http://matplotlib.sourceforge.net/api/artist_api.html?highlight=set_visible#matplotlib.artist.Artist.set_visible).
For interactive stuff, the following example may be a good starting
point (well, the example is in the svn trunk and I'm not sure if it
will run with older version of matplotlib).
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/examples/event_handling/legend_picking.py?revision=7351&view=markup
Regards,
-JJ
From: Marius 't H. <mar...@gm...> - 2009年09月02日 19:16:29
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<Chr...@no...>
>> 
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Stan W. <sta...@nr...> - 2009年09月02日 19:05:42
> On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barker<Chr...@no...>
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.
From: Ryan N. <rya...@gm...> - 2009年09月02日 18:33:14
Hello,
I've got many 1d arrays of data which contain occasional NaNs where there
weren't any samples at that depth bin. Something like this...
array([np.nan,1,2,3,np.nan,5,6,7,8,np.nan,np.nan,11,12,np.nan,np.nan,np.nan])
But much bigger, and I have hundreds of them. Most NaN's are isolated
between two valid values, but they still make my contour plots look
terrible.
Rather than just mask them, I want to interpolate so my plot doesn't have
holes in it where it need not.
I want to change any NaN which is preceded and followed by a value to the
average of those two values.
If it only has one valid neighbor, I want to change it to the values of it's
neighbor.
Here's a simplified version of my code:
from copy import copy
import numpy as np
sample_array =
np.array(([np.nan,1,2,3,np.nan,5,6,7,8,np.nan,np.nan,11,12,np.nan,np.nan,np.nan]))
#Make a copy so we aren't working on the original
cast = copy(sample_array)
#Now iterate over the copy
for j,sample in enumerate(cast):
 # If this sample is a NaN, let's try to interpolate
 if np.isnan(sample):
 #Get the neighboring values, but make sure we don't index out of
bounds
 prev_val = cast[max(j-1,0)]
 next_val = cast[min(j+1,cast.size-1)]
 print "Trying to fix",prev_val,"->",sample,"<-",next_val
 # First try an average of the neighbors
 inter_val = 0.5 * (prev_val + next_val)
 if np.isnan(inter_val):
 #There must have been an neighboring Nan, so just use the only
valid neighbor
 inter_val = np.nanmax([prev_val,next_val])
 if np.isnan(inter_val):
 print " No changes made"
 else:
 print " Fixed to",prev_val,"->",inter_val,"<-",next_val
 #Now fix the value in the original array
 sample_array[j] = inter_val
After this is run, we have:
sample_array = array([1,1,2,3,4,5,6,7,8,8,11,11,12,12,np.nan,np.nan])
This works, but is very slow for something that will be on the back end of a
web page.
Perhaps something that uses masked arrays and some of the numpy.ma methods?
I keep thinking there must be some much more clever way of doing this.
-Ryan
From: Shixin Z. <zen...@gm...> - 2009年09月02日 18:23:26
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<gr...@bi...> 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>
>
> 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
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
From: Shixin Z. <zen...@gm...> - 2009年09月02日 17:34:47
On Wed, Sep 2, 2009 at 11:43 AM, Christopher
Barker<Chr...@no...> 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
> 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.
> 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
>
> Chr...@no...
>
> ------------------------------------------------------------------------------
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Fabrice S. <si...@lm...> - 2009年09月02日 16:50:03
Le mercredi 02 septembre 2009 à 17:41 +0200, Sebastian Rhode a écrit :
> So I already figure out how to delete the last drawn line, but this is
> not a very good solution. What I actually would need, is a selection
> which line & legend the users whats to remove from the graph (perfect
> would be interactivly directly from the graph). But so far, I could
> not figure this out. Has anyone a good ides how to achieve this?
You may try to get the line to remove with 
	self.gex, = self.axes.plot(ex[:,0],ex[:,1],'b', lw=2,label = mypathex)
in openex (note the comma)
To remove the line, put
	self.gex.remove()
in delex function.
An alternative is
	self.axes.get_lines()[-1].remove()
so that you don't need self.gex for this.
Now, you need a function to interactively select the line. I don't have
a solution for that, but I'm interested too!
-- 
Fabrice Silva
Laboratory of Mechanics and Acoustics - CNRS
31 chemin Joseph Aiguier, 13402 Marseille, France.
From: Christopher B. <Chr...@no...> - 2009年09月02日 16:46:44
Chris Michalski wrote:
> Thanks for the inputs... perhaps it will provide the impetus for 
> future postings as well...
I think this would be a great addition to scipy.interpolate. I encourage 
you to massage your code to fit the API and scipy standards and 
contribute it.
-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
Chr...@no...
From: Shixin Z. <zen...@gm...> - 2009年09月02日 16:46:41
No, I'm not scaling it down actually, I use the exact size matplotlib
produces. So this is not a problem about scaling.
Best Regards
Shixin Zeng
On Wed, Sep 2, 2009 at 11:35 AM, Chip Webber<chi...@gm...> wrote:
> If Word has problems scaling down the png image for viewing maybe you could
> try writing the image out to a smaller size or using imagemagick to scale it
> to the size you need.
>
> Shixin Zeng wrote:
>>
>> Yes, with large pictures, PNG is good enough, but when scaling down,
>> it looks a bit fuzzy.
>>
>> Best Regards
>>
>> Shixin Zeng
>>
>
From: <jas...@cr...> - 2009年09月02日 16:44:54
Michael Droettboom wrote:
> jas...@cr... wrote:
>> I'm trying to deal nicely with the clipping that happens when, for 
>> example, a line has data that is inside its clipping box, but the 
>> linewidth forces part of the line to be drawn outside of the clipping 
>> box. This is visible on the spine placement demo at 
>> http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html, 
>> for example (the clipping at the top and bottom of most of the sine 
>> waves). This has been brought up here (or on the -devel list) 
>> before, and it was suggested to just set the clipping off, but that 
>> won't work in my case because sometimes I want to use that clipping 
>> box to limit the data shown.
>>
>> The best solution I can think of is to expand the clipping box by 
>> padding it with the line width. For something like a scatter plot, I 
>> would also be okay with expanding the clipping box by padding by the 
>> max radius of a circle in the circle collection. However, I can't 
>> quite figure out how to do this with the transform framework. If I 
>> just pad the clip box using the padded() method, it seems to make it 
>> a static Bbox instead of a TransformedBbox, and my line disappears. 
>> Can someone help?
>> 
> Yeah -- that sounds rather painful. We don't currently have a way to 
> dynamically grow a bbox like this and have it updated on 
> zooming/panning etc. I think what ultimately needs to happen is that 
> clipping is made aware of the spine placement (which is a relatively 
> new feature) and automatically deal with these small adjustments of 
> the clipping box. I'm thinking of the Axes clip_box becoming 
> something dynamically calculated based on the placement of the 
> spines. But I think it will be much harder to do it from the 
> outside. Of course, it's hard to say if this is the right thing to do 
> in the general case -- we'll always end up clipping some marker or 
> another if the limits of the axes are anything but the limits of the 
> actual data. Hmm... I'll have to think on this some more.
Thanks for thinking about this. My use-case (matplotlib in Sage) is 
just static pictures (at least until maybe the html5 canvas backend 
comes around!)
>> Another option I thought of was separating out masking the data from 
>> clipping the graphics. I suppose if I could get the data for the 
>> line and mask it to be within the clipbox, but then just set clipping 
>> off, I would still have the benefit of clipping things that were way 
>> outside of my bounding box, but letting things like an extra bit of 
>> linewidth through. However, this requires doing things like 
>> computing intersections of the line and the bounding box so that I 
>> can insert an extra point for the "end" of the line at the bounding 
>> box. This gets harder when the line is a spline or something like that.
>> 
> Do you care about panning and zooming, or are you just creating static 
> plots? If static, then you can just pass in a masked array as the 
> data and all of these things should be handled automatically (with the 
> exception of splines). Something like:
>
> In [1]: X = np.arange(0, np.pi * 2.0, 0.001)
>
> In [3]: Y = np.sin(X)
>
> In [4]: X = ma.masked_where(X > np.pi * 1.5, X)
>
> In [5]: Y = ma.masked_where((Y < -0.5) | (Y > 0.5), Y)
>
> In [6]: plot(X, Y)
I thought about this, but often, in Sage, we adjust the axes limits 
*after* we have plotted the data. So I would have to find all lines and 
circles and whatever else in the graph, get the data out, and mask it. 
Would I then have to redraw it too?
also, if it is a long, straight line defined by two points that goes out 
of the clip box, I probably want to insert a point at the intersection 
so it looks like the line is just being clipped. Between these two 
problems, it seemed like the better solution was just padding the clip 
box by the line width.
I'm still trying to understand the transformation system. In linear 
algebra, to make the box grow by just a bit, I would translate the clip 
box to the origin, scale by a certain amount (probably based on 
fig.dpi_scale_something_or_other), then translate the clip box back. 
Would this work? On the other hand, what if I hooked into the on_draw 
method and padded the clip box there, similar to the FAQ example of 
making really long text labels fit?
Thanks,
Jason
From: Christopher B. <Chr...@no...> - 2009年09月02日 16:42:33
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
Chr...@no...
From: Gary R. <gr...@bi...> - 2009年09月02日 16:28:32
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>
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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Nicolas B. <nbi...@gm...> - 2009年09月02日 15:48:45
Have you read these?
http://www.scipy.org/Cookbook/Matplotlib/Animations
http://matplotlib.sourceforge.net/examples/animation/index.html?highlight=animation
What I normally do is plot everything (forget about interactive mode, its
just too slow) and get handles to curves, then update the curves values.
With this you don't need to redraw _everything_ each time you add a new
element.
I remember reading a page about animation and backends, but I can't find it
anymore, maybe the previous links can help you.
Good luck
2009年9月2日 RazAlon <raz...@we...>
>
> Hi,
>
> I wish to have several (about 3) plots which are updated about once per
> second, as part of some application that's monitoring an instrument.
>
> I set pyplot to interactive mode. I create as many figures as I need, and
> then I simply plot to them whenever I have new data coming in (each time I
> plot a new x and y vectors, I don't know if it's possible just to append
> data points to existing plots).
>
> I work on windows xp with the default matplotlib settings.
>
> This procedure is very slow. The plots take ages to update.
>
> Is there a faster way to do that?
>
> Thank you,
> Raz
>
>
>
> --
> View this message in context:
> http://www.nabble.com/how-to-update-plots-fast-tp25252745p25252745.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Sebastian R. <seb...@go...> - 2009年09月02日 15:41:53
Hello,
I wrote a little program to display the spectral data of varoius filters.
Here is a part of the code:
...
def openex(self, event):
 dlg = wx.FileDialog(self, "Choose a Excitation Filter", os.getcwd(),
"", "*.ex*", wx.OPEN)
 if dlg.ShowModal() == wx.ID_OK:
 pathex = dlg.GetPath()
 mypathex = os.path.basename(pathex)
 self.SetStatusText("Selected EX: %s" % mypathex)
 ex = load(pathex)
 ex = normspec_filter(ex)
 self.gex = self.axes.plot(ex[:,0],ex[:,1],'b', lw=2,label =
mypathex)
 self.axes.axis([xmin,xmax,ymin,ymax])
 self.axes.legend(loc=4)
 self.plotPanel.draw()
 dlg.Destroy()
 def delex(self, event):
 *self.axes.lines.remove(self.gex[-1])*
 self.plotPanel.draw()
...
So I already figure out how to delete the last drawn line, but this is not a
very good solution. What I actually would need, is a selection which line &
legend the users whats to remove from the graph (perfect would be
interactivly directly from the graph). But so far, I could not figure this
out. Has anyone a good ides how to achieve this?
Cheers,
Sebi
-- 
Dr. Sebastian Rhode
Grünwalder Str. 103a
81547 München
Tel: +49 89 4703091
seb...@go...
From: Michael D. <md...@st...> - 2009年09月02日 13:24:48
jas...@cr... wrote:
> I'm trying to deal nicely with the clipping that happens when, for 
> example, a line has data that is inside its clipping box, but the 
> linewidth forces part of the line to be drawn outside of the clipping 
> box. This is visible on the spine placement demo at 
> http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html, 
> for example (the clipping at the top and bottom of most of the sine 
> waves). This has been brought up here (or on the -devel list) before, 
> and it was suggested to just set the clipping off, but that won't work 
> in my case because sometimes I want to use that clipping box to limit 
> the data shown.
>
> The best solution I can think of is to expand the clipping box by 
> padding it with the line width. For something like a scatter plot, I 
> would also be okay with expanding the clipping box by padding by the max 
> radius of a circle in the circle collection. However, I can't quite 
> figure out how to do this with the transform framework. If I just pad 
> the clip box using the padded() method, it seems to make it a static 
> Bbox instead of a TransformedBbox, and my line disappears. Can someone 
> help?
> 
Yeah -- that sounds rather painful. We don't currently have a way to 
dynamically grow a bbox like this and have it updated on zooming/panning 
etc. I think what ultimately needs to happen is that clipping is made 
aware of the spine placement (which is a relatively new feature) and 
automatically deal with these small adjustments of the clipping box. 
I'm thinking of the Axes clip_box becoming something dynamically 
calculated based on the placement of the spines. But I think it will be 
much harder to do it from the outside. Of course, it's hard to say if 
this is the right thing to do in the general case -- we'll always end up 
clipping some marker or another if the limits of the axes are anything 
but the limits of the actual data. Hmm... I'll have to think on this 
some more.
> Another option I thought of was separating out masking the data from 
> clipping the graphics. I suppose if I could get the data for the line 
> and mask it to be within the clipbox, but then just set clipping off, I 
> would still have the benefit of clipping things that were way outside of 
> my bounding box, but letting things like an extra bit of linewidth 
> through. However, this requires doing things like computing 
> intersections of the line and the bounding box so that I can insert an 
> extra point for the "end" of the line at the bounding box. This gets 
> harder when the line is a spline or something like that.
> 
Do you care about panning and zooming, or are you just creating static 
plots? If static, then you can just pass in a masked array as the data 
and all of these things should be handled automatically (with the 
exception of splines). Something like:
In [1]: X = np.arange(0, np.pi * 2.0, 0.001)
In [3]: Y = np.sin(X)
In [4]: X = ma.masked_where(X > np.pi * 1.5, X)
In [5]: Y = ma.masked_where((Y < -0.5) | (Y > 0.5), Y)
In [6]: plot(X, Y)
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Ewald Z. <ewa...@gm...> - 2009年09月02日 13:23:13
Hi All,
I'm trying to make a simple errorbar plot which gets saved to an EPS file. I
paste the code below. For some weird reason, the savefig line causes a
segmentation fault in ghostscript. when I use (in this case, on my computer)
206 points or more. It doesn't happen if I comment the "pl.rc('text',
usetex=True)" line out nor does it happen if I comment the pl.savefig line
out. This happens in matplotlib 0.99 and 0.98.5.2. Any help will be greatly
appreciated.
Regards,
Ewald Zietsman
#test.py
import matplotlib.pyplot as pl
import numpy as np
pl.rc('text', usetex=True)
pl.rc('font', family='serif')
N = 206
x1 = np.linspace(-10,10,N)
e1 = np.random.randn(N)
pl.errorbar(x1, x1, yerr=e1, fmt='k.')
pl.savefig('test.eps')
pl.show()
The error message:
 python test.py
Segmentation fault
Traceback (most recent call last):
 File "test.py", line 16, in <module>
 pl.savefig('test.eps')
 File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 345, in
savefig
 return fig.savefig(*args, **kwargs)
 File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 990, in
savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py", line
1419, in print_figure
 **kwargs)
 File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py", line
1308, in print_eps
 return ps.print_eps(*args, **kwargs)
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py",
line 869, in print_eps
 return self._print_ps(outfile, 'eps', *args, **kwargs)
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py",
line 892, in _print_ps
 orientation, isLandscape, papertype)
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py",
line 1148, in _print_figure_tex
 else: gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox)
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py",
line 1268, in gs_distill
 your image.\nHere is the full report generated by ghostscript:\n\n' +
fh.read())
RuntimeError: ghostscript was not able to process your image.
Here is the full report generated by ghostscript:
GPL Ghostscript 8.63 (2008年08月01日)
Copyright (C) 2008 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading CenturySchL-Roma font from
/var/lib/defoma/gs.d/dirs/fonts/c059013l.pfb... 3423696 1832182 6023256
4166010 1 done.
From: Pim S. <P.S...@st...> - 2009年09月02日 10:00:13
Hi Everyone,
I compiled the latest matplotlib against python 2.5.4 on OSX Leopard
(Tcl/Tk 8.4 default installation from OSX).
It complained about not finding the freetype headers but this was
fixed by including /usr/local in the darwin list (which is by default
empty?) in setupext.py.
This might be a bug in the latest trunk, can anyone else test this on OSX?
Now when I try to run the GUI example on:
http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk.html
I get the following errors:
python test.py
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(64196,0xa0427720) malloc: *** error for object 0xa00726d8:
Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Segmentation fault
Does anyone know what might be wrong here?
Kind regards,
Pim Schellart
P.S. I tried the same with a MacPython 2.6 installation and get
similar errors (see previous post).
From: Sebastian P. <spc...@gm...> - 2009年09月02日 09:33:44
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 <zen...@gm...>:
> 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 http://ftp.gnome.org/pub/gnome/binaries/win32/
>
> Best Regards
>
> Shixin Zeng
>
>
>
> On Tue, Sep 1, 2009 at 6:43 PM, Shixin Zeng<zen...@gm...> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: RazAlon <raz...@we...> - 2009年09月02日 07:18:13
Hi,
I wish to have several (about 3) plots which are updated about once per
second, as part of some application that's monitoring an instrument.
I set pyplot to interactive mode. I create as many figures as I need, and
then I simply plot to them whenever I have new data coming in (each time I
plot a new x and y vectors, I don't know if it's possible just to append
data points to existing plots).
I work on windows xp with the default matplotlib settings.
This procedure is very slow. The plots take ages to update.
Is there a faster way to do that?
Thank you,
Raz
-- 
View this message in context: http://www.nabble.com/how-to-update-plots-fast-tp25252745p25252745.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Shixin Z. <zen...@gm...> - 2009年09月02日 06:33:07
Attachments: main.c
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 http://ftp.gnome.org/pub/gnome/binaries/win32/
Best Regards
Shixin Zeng
On Tue, Sep 1, 2009 at 6:43 PM, Shixin Zeng<zen...@gm...> 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
>
From: Scott S. <sco...@gm...> - 2009年09月02日 06:02:11
Forgot to copy the list.
---------- Forwarded message ----------
From: Scott Sinclair <sco...@gm...>
Date: 2009年9月2日
Subject: Re: [Matplotlib-users] best format for MS word?
To: Shixin Zeng <zen...@gm...>
> 2009年9月2日 Shixin Zeng <zen...@gm...>:
> 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.
Word seems to make PNG's very fuzzy when it needs to rescale them. Two
options I can think of are:
1. Try to size the figure so that Word imports it at 100% without
scaling (play with the following)
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> ax.plot([1,2,3])
>>> fig.set_size_inches((4, 3))
>>> plt.savefig('figure.png', dpi=600)
2. Save your figures as PDF's and view at large magnification in Adobe
Reader, then use the image select? tool to copy the image to your
clipboard. In Word Edit-Paste-Special as an enhanced metafile.
Cheers,
Scott
From: <jas...@cr...> - 2009年09月02日 04:23:34
I'm trying to deal nicely with the clipping that happens when, for 
example, a line has data that is inside its clipping box, but the 
linewidth forces part of the line to be drawn outside of the clipping 
box. This is visible on the spine placement demo at 
http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html, 
for example (the clipping at the top and bottom of most of the sine 
waves). This has been brought up here (or on the -devel list) before, 
and it was suggested to just set the clipping off, but that won't work 
in my case because sometimes I want to use that clipping box to limit 
the data shown.
The best solution I can think of is to expand the clipping box by 
padding it with the line width. For something like a scatter plot, I 
would also be okay with expanding the clipping box by padding by the max 
radius of a circle in the circle collection. However, I can't quite 
figure out how to do this with the transform framework. If I just pad 
the clip box using the padded() method, it seems to make it a static 
Bbox instead of a TransformedBbox, and my line disappears. Can someone 
help?
Here is the example code I'm using. I don't know what to put in for the 
???, which is all that I think I need.
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([0,1],[1,1],lw=20)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.set_ylim([0,1])
line=ax.lines[0]
# I still want clipping for things that are outside of the original clip 
box+linewidth padding
# so I don't want to take off clipping; I guess it doesn't matter for 
this example, but it does for
# more complicated examples.
#line.set_clip_on(False)
bb=line.get_clip_box()
# How can I pad bb so that it is padded by 
linewidth/2*1.0/72*fig.dpi_scale_trans.transform_point([1,1]) dots?
padded_bb=???
line.set_clip_box(padded_bb)
fig.savefig('test.png')
Another option I thought of was separating out masking the data from 
clipping the graphics. I suppose if I could get the data for the line 
and mask it to be within the clipbox, but then just set clipping off, I 
would still have the benefit of clipping things that were way outside of 
my bounding box, but letting things like an extra bit of linewidth 
through. However, this requires doing things like computing 
intersections of the line and the bounding box so that I can insert an 
extra point for the "end" of the line at the bounding box. This gets 
harder when the line is a spline or something like that.
Thanks for being patient with me while I learn my way around 
matplotlib's excellent transformation framework.
Jason
--
Jason Grout
From: Shixin Z. <zen...@gm...> - 2009年09月02日 03:54:17
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<ef...@ha...> 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
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

Showing results of 31

1 2 > >> (Page 1 of 2)
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 によって変換されたページ (->オリジナル) /