[Matplotlib-users] Fwd: best format for MS word?

2009-09-02 Thread Scott Sinclair
Forgot to copy the list.


-- Forwarded message --
From: Scott Sinclair scott.sinclair...@gmail.com
Date: 2009/9/2
Subject: Re: [Matplotlib-users] best format for MS word?
To: Shixin Zeng zeng.shi...@gmail.com


 2009/9/2 Shixin Zeng zeng.shi...@gmail.com:
 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

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Shixin Zeng
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 Zengzeng.shi...@gmail.com 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

/* A simple program that converts an svg file to an emf file
 * based on librsvg and cairo
 *
 * Author Shixin Zeng zeng.shi...@gmail.com
 * License: GPL V2 or newer
 **/

#include cairo.h
#include librsvg/rsvg.h

#include windows.h

//#define FACTOR_INCH_TO_MM 25.4
//#define DPI   90

//static double dpi = 90;
static char *src = NULL;
static char *dest = NULL;
static GOptionEntry entries[] =
{
//{dpi, 'd', 0, G_OPTION_ARG_DOUBLE, dpi, the source dpi, dpi},
{from, 'f', 0, G_OPTION_ARG_STRING, src, the source file, src},
{to, 't', 0, G_OPTION_ARG_STRING, dest, the destination file, 
dest},
{NULL}
};

int
main (int argc, char *argv[])
{
cairo_surface_t *surface;
cairo_t *cr;
HDC hdc;
RsvgHandle * rsvg_hd = NULL;
RsvgDimensionData rdim;
HDC dc = GetDC(NULL);
RECT dim;
float MetaPixelsX, MetaPixelsY;
float MetaMMX, MetaMMY;


int i = 1;
GError *error = NULL;
GOptionContext *context;

context = g_option_context_new(Convert SVG to EMF);
g_option_context_add_main_entries(context, entries, SVG_TO_EMF);
if(!g_option_context_parse(context, argc, argv, error))
{
g_print(option parsing failed: %s\n, error-message);
return 1;
}

if (src == NULL || dest == NULL){
g_print(source and dest files must be given\n%s, 
g_option_context_get_help(context, TRUE, NULL));
return 1;
}

rsvg_init();
rsvg_hd = rsvg_handle_new_from_file(src, NULL);

//dpi =  GetDeviceCaps(dc, HORZRES);
//rsvg_handle_set_dpi (rsvg_hd, dpi); 
rsvg_handle_get_dimensions(rsvg_hd, rdim);

g_print(SVG: height = %d pt, width = %d pit\n, rdim.height, 
rdim.width);

/* MetaPixelsX = MetaWidthMM * MetaPixels / (MetaMM * 100)
 *
 * where MetaPixelsX = number of pixels on the X axis
 * MetaWidthMM = metafile width in 0.01mm units
 * MetaPixels  = width in pixels of the reference device
 * MetaMM  = width in millimeters of the reference device
 * 
 * MetaWidthMM = MetaPixelsx * MetaMM * 100 / MetaPixels
 */

MetaPixelsX =  GetDeviceCaps(dc, HORZRES);
MetaPixelsY =  GetDeviceCaps(dc, VERTRES);

MetaMMX = GetDeviceCaps(dc, HORZSIZE);
MetaMMY = GetDeviceCaps(dc, VERTSIZE);

dim.left = 0;
dim.top = 0;
dim.bottom = rdim.height * MetaMMY * 100 / MetaPixelsY;
dim.right = rdim.width * MetaMMX * 100 / MetaPixelsX;

g_print(EMF: height = %d mm, width = %d mm\n, dim.bottom/100, 
dim.right/100);
hdc = CreateEnhMetaFile(dc, 
dest,
dim,
NULL);
ReleaseDC(NULL, dc);
if(!hdc){
g_print(creating emf file failed\n);
return 1;
}

surface = cairo_win32_printing_surface_create (hdc);
cr = cairo_create(surface);
if(!rsvg_handle_render_cairo(rsvg_hd, cr))
g_print(render to cairo failed\n);

cairo_destroy (cr);
cairo_surface_destroy (surface);

CloseEnhMetaFile(hdc);


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Sebastian Pająk
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.shi...@gmail.com:
 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 Zengzeng.shi...@gmail.com 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
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] User interface example malloc error and possible installation bug

2009-09-02 Thread Pim Schellart
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 

Re: [Matplotlib-users] clipping and linewidth/circle radius

2009-09-02 Thread Michael Droettboom
jason-s...@creativetrax.com 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


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Segmentation fault with EPS output on matplotlib =0.98.5.2

2009-09-02 Thread Ewald Zietsman
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.
--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to update plots fast

2009-09-02 Thread RazAlon

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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Delete Line legend from graph using matplotlib wxPython

2009-09-02 Thread Sebastian Rhode
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
sebrh...@googlemail.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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to update plots fast

2009-09-02 Thread Nicolas Bigaouette
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.a...@weizmann.ac.il


 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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Gary Ruben
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=Productsproduct=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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Christopher Barker
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/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] clipping and linewidth/circle radius

2009-09-02 Thread jason-sage
Michael Droettboom wrote:
 jason-s...@creativetrax.com 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


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Shixin Zeng
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 Webberchipweb...@gmail.com 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



--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Piecewise Cubic Hermite Interpolating Polynomial in python

2009-09-02 Thread Christopher Barker
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/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Delete Line legend from graph using matplotlib wxPython

2009-09-02 Thread Fabrice Silva
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.


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Shixin Zeng
On Wed, Sep 2, 2009 at 11:43 AM, Christopher
Barkerchris.bar...@noaa.gov 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/ORR            (206) 526-6959   voice
 7600 Sand Point Way NE   (206) 526-6329   fax
 Seattle, WA  98115       (206) 526-6317   main reception

 chris.bar...@noaa.gov

 --
 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
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Shixin Zeng
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 Rubengru...@bigpond.net.au 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=Productsproduct=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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Stan West
 On Wed, Sep 2, 2009 at 11:43 AM, Christopher Barkerchris.bar...@noaa.gov
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Delete Line legend from graph using matplotlib wxPython

2009-09-02 Thread Jae-Joon Lee
On Wed, Sep 2, 2009 at 11:41 AM, Sebastian Rhodesebrh...@googlemail.com 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=7351view=markup

Regards,

-JJ

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Filling in missing samples by interpolating.

2009-09-02 Thread Ryan Neve
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):
printNo changes made
else:
printFixed 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
--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Marius 't Hart
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 Barkerchris.bar...@noaa.gov
 
 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
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] imshow and pcolor differences

2009-09-02 Thread Richard McMahon

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.   | mobile7885-409019
 Office: Hoyle 18  | home  1223-359770
---
 email: r...@ast.cam.ac.uk  | WWW:http://www.ast.cam.ac.uk/~rgm
 richardgmcma...@gmail.com | skype:richardgmcmahon
---

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Alan G 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.

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

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] imshow and pcolor differences

2009-09-02 Thread Ryan May

 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.


pass in interpolation='nearest' as a keyword argument.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] imshow and pcolor differences

2009-09-02 Thread Eric Firing
Richard McMahon wrote:
 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.

This is not a matter of resampling (unless I am misunderstanding 
you)--it is a difference in the grid.  For imshow and contour, the data 
points and the grid intersections coincide; for pcolor (and pcolormesh), 
the grid gives the boundaries of colored quadrilaterals. Therefore, if 
the data array is MxN, then the the grid X dimension should be N+1 and 
the grid Y dimension should be M+1.

For an example of how to use contours with images, see:

http://matplotlib.sourceforge.net/examples/pylab_examples/contour_image.html

Also, it sounds like maybe you don't want imshow to interpolate: try 
using the interpolation='nearest' kwarg.

If you do want to use pcolor or pcolormesh or Axes.pcolorfast, then you 
can still get square pixels by suitable choice of aspect ratio.  Try 
axis('equal') or axis('scaled'), or axis('image'),  or use the 
set_aspect() method of the Axes instance.

Eric

 
 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.   | mobile7885-409019
  Office: Hoyle 18  | home  1223-359770
 ---
  email: r...@ast.cam.ac.uk  | WWW:http://www.ast.cam.ac.uk/~rgm
  richardgmcma...@gmail.com | skype:richardgmcmahon
 ---
 
 --
 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
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] best format for MS word?

2009-09-02 Thread Stan West
 -Original Message-
 From: Shixin Zeng [mailto:zeng.shi...@gmail.com] 
 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.

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?


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Fwd: best format for MS word?

2009-09-02 Thread Shixin Zeng
Forgot CC list.

Thanks for your helps.

Best Regards

Shixin Zeng




-- Forwarded message --
From: Shixin Zeng zeng.shi...@gmail.com
Date: Wed, Sep 2, 2009 at 11:02 PM
Subject: Re: [Matplotlib-users] best format for MS word?
To: Stan West stan.w...@nrl.navy.mil


On Wed, Sep 2, 2009 at 8:59 PM, Stan Weststan.w...@nrl.navy.mil wrote:
 -Original Message-
 From: Shixin Zeng [mailto:zeng.shi...@gmail.com]
 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.

 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?


I'm not sure if my printer supports PS or not, it's Dell Laser 1320c,
I couldn't find any information from its property page.

I'm afraid that I'm giving up matplotlib for my paper plotting, since
my professor wants me to do plotting with excel such that he doesn't
have to ask me to do every small change on the plot if he could do it
himself.

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users