hi i have been trying  to use pcolor and/or contour to make a contor map
or intensity map
i want to do an intensity or contour map of an electric field 
i have an array (or list) of points [x,y] and for each point i have the 
respective value of the electric field (in another list) 
 
i have tried the examples in matplotlib  but they are different because they 
use meshgrid
and from the points calculated in the mesh get values and plot...
in my case i want to plot directly...each poin (x,z) its magnitude(E_fiel_Mag)
i do not think i need to use meshgrid any more how can i do my plot?
below is my code...pls help me!!!

#!/usr/bin/env python

# This example demonstrates how to use a constraint polygon in
# Delaunay triangulation.

from scipy import*
from pylab import*

read_file= open ('W:/Serio/necfile.out','r')

L =read_file.readlines()
                
fieldlist =[]
f = 0
for line in L:
        f=f+1
        if 'NEAR ELECTRIC FIELDS'in line:

                rpoints = 3
                phipoints = 3
                tetapoints = 1
                
                for line in range (f+3,f+4+rpoints*phipoints*tetapoints):
                        fieldlist.append(L[line])
                        
Ex = [];Ey = [];Ez = []
x1 =[];y1=[];z1=[]
Exphase=[]; Eyphase=[]; Ezphase=[]
                
for i in range(len(fieldlist)-1):
       
        splitlines= fieldlist[i].split()
        
        x1.append(float(splitlines[0]))     #here we pick up the x,y,x 
coordinates of the points
        y1.append(float(splitlines[1]))     #where the manitude has been 
calculated
        z1.append(float(splitlines[2]))

        Ex.append(float(splitlines[3]))     #pick up the e-filed magnitudes
        Ey.append(float(splitlines[5]))     #u append as floats instead os 
string for later calculations
        Ez.append(float(splitlines[7]))

        Exphase.append(float(splitlines[4])) # pick up the phases just in case 
they are needed
        Eyphase.append(float(splitlines[6]))
        Ezphase.append(float(splitlines[8]))
read_file.close()        
                

# i want to see if i can calculate the magnitude of the electric field

E_field_Mag = []
for i in range(len(Ex)):
    E_Magnitude = sqrt((Ex[i])**2 + (Ey[i])**2+(Ez[i])**2)
    E_field_Mag.append(E_Magnitude)
    
#E_field_Mag = array(E_field_Mag)

#y values are  zero
#X,Z = meshgrid(x1, z1)

pcolor(x1,y1,E_field_Mag)










----- Mensaje original ----
De: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Para: matplotlib-users@lists.sourceforge.net
Enviado: domingo, 30
 de septiembre, 2007 12:53:11
Asunto: Matplotlib-users Digest, Vol 16, Issue 32

Send Matplotlib-users mailing list submissions to
    matplotlib-users@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users
or, via email, send a message with subject or body 'help' to
    [EMAIL PROTECTED]

You can reach the person managing the list at
    [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Matplotlib-users digest..."


Today's Topics:

   1. Re: NameError: global name '__loader__' is not
 defined
      (Eric Firing)
   2. Re: plot cdf (Alan G Isaac)
   3. Re: edgecolor with usetex=True,    usedistiller='pdf' (Darren Dale)
   4. Re: Problem with tick labels in scripts (John Hunter)
   5. Using special characters (David Loyall)
   6. Re: matplotlib - representation of nan values in    2D
      (Dirk Zickermann)


----------------------------------------------------------------------

Message: 1
Date: Thu, 27 Sep 2007 14:46:13 -1000
From: Eric Firing <[EMAIL PROTECTED]>
Subject: Re: [Matplotlib-users] NameError: global name '__loader__' is
    not defined
To: Hal Huntley <[EMAIL PROTECTED]>
Cc: matplotlib-users@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type:
 text/plain; charset=ISO-8859-1; format=flowed

Hal Huntley wrote:
> Thanks to Eric Firing and Christopher Barker for input on trying to
> resolve the problem.  Christopher said:
> %%%
> You might try just:
> 
> easy_install numpy
> 
> easy_install matplotlib.
> %%%
> 
> 
> I did that and now the problem moved and I get:
> ===
>>>> from pylab import *
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File
>   
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/pylab.py",
>  line 1, in ?
>     from matplotlib.pylab import *
>   File
>   
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/pylab.py",
>  line 222, in ?
>    
 new_figure_manager, draw_if_interactive, show = pylab_setup()
>   File
>   
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/__init__.py",
>  line 24, in pylab_setup
>     globals(),locals(),[backend_name])
>   File
>   
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/backend_gtkagg.py",
>  line 10, in ?
>     from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK,
>     FigureCanvasGTK,\
>   File
>   
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/backend_gtk.py",
>  line 21, in ?
>     from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
>   File
>  
 
"/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/backend_gdk.py",
 line 35, in ?
>     from matplotlib.backends._ns_backend_gdk import pixbuf_get_pixels_array
> ImportError: No module named _ns_backend_gdkd4
> ===

Is it a rotten egg?

> 
> Googling around has indicated that the X11 stuff wasn't available when the
> numpy and matplotlib were made. The gtk files and "-devel" seem to be there
> when I do an "rpm -qa".  I went and got a new numpy from source and did
> "python setup.py install".  It is interesting that when I get in to python
> now, I can do:
> 
>>>> import gtk
>>>> import numpy
>>>> import matplotlib
> 
> and they all just return the prompt, indicating, I thought, that the
> programs were installed ok.  
>
 
> Here is the naive question ->  Is there something wrong, then with a
> "from pylab import *"? The user is trying to do that. 

No, that should work fine.  I don't know how the egg-based 
matplotlib/pylab should work with the installed-from-source numpy, 
though.  If the versions are compatible, then I expect it would work.

You gave a traceback resulting from "from pylab import *" after 
installing the two eggs, correct?  If so, what was the result after you 
installed numpy from source?  I would expect no difference, because the 
problem reported in the traceback is a missing matplotlib module, not a 
missing numpy module.

Or did you mean that you installed matplotlib from source?  That would 
make more sense, and certainly should work if all the right header files 
and libraries are present.

If you installed matplotlib from
 source, what do you get from
ls /usr/lib/python2.4/site-packages/matplotlib/backends/*.so

Another diagnostic would be to delete the build directory from the 
matplotlib source tree (assuming you are now building matplotlib from 
source), and save the output from the "python setup.py build" command. 
This should make it clear whether the necessary headers really were found.

Eric



------------------------------

Message: 2
Date: Fri, 28 Sep 2007 00:18:13 -0400
From: Alan G Isaac <[EMAIL PROTECTED]>
Subject: Re: [Matplotlib-users] plot cdf
To: matplotlib-users@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type: TEXT/PLAIN; CHARSET=UTF-8

After thinking it over, I did not go for
Robert or David's cool numpy tricks, but
I'll append a simple object in case someone
else wants to do more.

Cheers,
Alan
 Isaac

class EmpiricalCDF(object):
    '''Empirical cdf.
    First point will be (xmin,0).
    Last point will be (xmax,1).
    '''
    def __init__(self, data, sortdata=True):
        if sortdata:
            data = N.sort(data)
        self.data = data
        self.nobs = len(data)
    def gen_xp(self):
        data, nobs = self.data, self.nobs
        prob = N.linspace(0, 1, nobs+1)
        xsteps = ( data[(idx)//2] for idx in xrange(2*nobs)
 )
        psteps = ( prob[(idx+1)//2] for idx in xrange(2*nobs) )
        return xsteps, psteps
    def get_steps(self):
        '''Return: 2-tuple of arrays,
        the data values and corresponding cumulative 
        probabilities.
        '''
        xsteps, psteps = self.gen_xp()
        return N.fromiter(xsteps,'f'), N.fromiter(psteps,'f')






------------------------------

Message: 3
Date: Fri, 28 Sep 2007 08:23:17 -0400
From: Darren Dale <[EMAIL PROTECTED]>
Subject: Re: [Matplotlib-users] edgecolor with
 usetex=True,
    usedistiller='pdf'
To: "John Hunter" <[EMAIL PROTECTED]>
Cc: matplotlib-users <matplotlib-users@lists.sourceforge.net>,    Eric
    Firing <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain;  charset="iso-8859-1"

On Friday 28 September 2007 07:36:23 am John Hunter wrote:
> On 9/27/07, Darren Dale <[EMAIL PROTECTED]> wrote:
> > Hi Eric, John,
> >
> > Have either of you been following this thread?
>
> I am now :-)
>
> As Eric suggests, None is overloaded vis-a-vis color handling, because
> for mpl properties it generally means do the default as defined by rc.
>  For colors people often want to use None for "no color" which is why
> we added support for the string "None".  Does
 this work in your use
> case Tom?

The above exchange was off-list, we're back on now. I think that would be what 
Tom is looking for, but it doesnt work:

In [1]: plot([1,2])
Out[1]: [<matplotlib.lines.Line2D instance at 0x710cb0>]

In [2]: savefig('dsd.png', facecolor='None', edgecolor='None')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/darren/<ipython console> in <module>()

/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py in savefig(*args, 
**kwargs)
    272 def savefig(*args, **kwargs):
    273     fig = gcf()
-->
 274     return fig.savefig(*args, **kwargs)
    275 if Figure.savefig.__doc__ is not None:
    276     savefig.__doc__ = dedent(Figure.savefig.__doc__)

/usr/lib64/python2.5/site-packages/matplotlib/figure.py in savefig(self, 
*args, **kwargs)
    768                 kwargs[key] = rcParams['savefig.%s'%key]
    769
--> 770         self.canvas.print_figure(*args, **kwargs)
    771
    772     def colorbar(self, mappable, cax=None, **kw):

/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py in 
print_figure(self, *args,
 **kwargs)
    153         self.update(l, self.renderer.height-t, w, h)
    154
    155     def print_figure(self, *args, **kwargs):
--> 156         FigureCanvasAgg.print_figure(self, *args, **kwargs)
    157         self.draw()

/usr/lib64/python2.5/site-packages/matplotlib/backend_bases.py in 
print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, 
**kwargs)
   1194                 edgecolor=edgecolor,
   1195                 orientation=orientation,
->
 1196                 **kwargs)
   1197         finally:
   1198             self.figure.dpi.set(origDPI)

/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py in 
print_png(self, filename, *args, **kwargs)
    415
    416     def print_png(self, filename, *args, **kwargs):
--> 417         self.draw()
    418         self.get_renderer()._renderer.write_png(str(filename))
    419

/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py in
 
draw(self)
    140         if DEBUG: print "FigureCanvasQtAgg.draw", self
    141         self.replot = True
--> 142         FigureCanvasAgg.draw(self)
    143         self.update()
    144

/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py in 
draw(self)
    377
    378         self.renderer = self.get_renderer()
--> 379         self.figure.draw(self.renderer)
    380
    381     def get_renderer(self):

/usr/lib64/python2.5/site-packages/matplotlib/figure.py in
 draw(self, 
renderer)
    586         self.transFigure.freeze()  # eval the lazy objects
    587
--> 588         if self.frameon: self.figurePatch.draw(renderer)
    589
    590         for p in self.patches: p.draw(renderer)

/usr/lib64/python2.5/site-packages/matplotlib/patches.py in draw(self, 
renderer)
    198         #renderer.open_group('patch')
    199         gc = renderer.new_gc()
--> 200         gc.set_foreground(self._edgecolor)
    201        
 gc.set_linewidth(self._linewidth)
    202         gc.set_alpha(self._alpha)

/usr/lib64/python2.5/site-packages/matplotlib/backend_bases.py in 
set_foreground(self, fg, isRGB)
    617             self._rgb = fg
    618         else:
--> 619             self._rgb = colors.colorConverter.to_rgb(fg)
    620
    621     def set_graylevel(self, frac):

/usr/lib64/python2.5/site-packages/matplotlib/colors.py in to_rgb(self, arg)
    277
    278         except (KeyError, ValueError, TypeError), exc:
-->
 279             raise ValueError('to_rgb: Invalid rgb arg "%s"\n%s' % 
(str(arg), exc))
    280             # Error messages could be improved by handling TypeError
    281             # separately; but this should be rare and not too hard

ValueError: to_rgb: Invalid rgb arg "None"
invalid literal for float(): None



------------------------------

Message: 4
Date: Fri, 28 Sep 2007 07:41:35 -0500
From: "John Hunter" <[EMAIL PROTECTED]>
Subject: Re: [Matplotlib-users] Problem with tick labels in scripts
To: "Charles Seaton" <[EMAIL PROTECTED]>
Cc:
 matplotlib-users@lists.sourceforge.net
Message-ID:
    <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

On 9/27/07, Charles Seaton <[EMAIL PROTECTED]> wrote:

> I am having the same problem as Eugen, and the suggested solution of using
> a.xaxis.get_major_locator().refresh()
> to force the creation of the full set of ticklabels doesn't seem to work for
> me.

matplotlib creates a prototypical tick (the prototick) and then
creates new ones on as as needed basis, copying properties from the
prototick.  Of course, position is one of the properties that cannot
be copied, which is why you are having trouble in your example.
Fortunately, there is an easy solution.

Call ax.xaxis.get_major_ticks() and access the label attribute:

for tick in ax.xaxis.get_major_ticks():
  
 label = tick.label1

Axis.get_major_ticks  will force a call to the locator and update the
tick list.  The Axes methods like get_xticklabels are just working on
the existing tick list rather than calling the get_major_ticks method
which is why you are not getting the full list.  This is a bug.  I
just made changes in svn so that all the accessor methods
(ax.get_xticklines, ax.get_yticklabels, and friends) all trigger a
call to axis.get_major_ticks rather so they should give the same
results going forward.


JDH


FYI, the Tick attributes are:

      tick1line  : a Line2D instance
      tick2line  : a Line2D instance
      gridline   : a Line2D instance
      label1     : a Text
 instance
      label2     : a Text instance
      gridOn     : a boolean which determines whether to draw the tickline
      tick1On    : a boolean which determines whether to draw the 1st tickline
      tick2On    : a boolean which determines whether to draw the 2nd tickline
      label1On   : a boolean which determines whether to draw tick label
      label2On   : a boolean which determines whether to draw tick label



------------------------------

Message: 5
Date: Sat, 29 Sep 2007 21:50:02 -0500
From: "David Loyall" <[EMAIL PROTECTED]>
Subject: [Matplotlib-users] Using special characters
To:
 matplotlib-users@lists.sourceforge.net
Message-ID:
    <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8

Hello.

I've been having trouble getting Unicode characters to render.  I just
get a box in the title of my figure, rather than the character I need.

Here is my code:
#!/usr/bin/env python
from pylab import *
plot([1,2,3,4])
title(u"\u0251")
savefig("test.eps")
savefig("test.png")
show()

That character is LATIN SMALL LETTER ALPHA.  It's used in the
International Phonetic Alphabet.

I'm on Linux and I'm using matplotlib 0.90.1-2 (debian package
version).  I have a few TTF fonts in my system that contain that
glyph.  One is 'Arial Unicode MS', which I copied from my windows
machine.

As you can see, I will need to generate an EPS that renders
 the
character...  That EPS file will be imported into MS Word on a Windows
PC and printed.

I will happily use any solution that allows me to use that character
in the final product... :)  It doesn't have to be unicode..

I believe that my fonts are configured correctly on this Linux
system--I can use the Arial Unicode MS font in Open Office.  However,
I'm not sure that MPL is finding them.

When I point the TTFPATH environment variable a directory that only
contains ARIALUNI.TTF, I get gibberish for all characters in my
figure.

When I use ~/.matplotlib/matplotlibrc to list Arial Unicode MS as the
only font in the san-serif family, I don't observe any change in the
text in the figure.

...I did successfully instantiate an FT2FONT object out of my
ARIALUNI.TTF file, but, I didn't know what to do with it at that
point.

Help?

Cheers,
--Dave
 Loyall
Omaha, Nebraska, USA



------------------------------

Message: 6
Date: Sun, 30 Sep 2007 12:53:06 +0200
From: "Dirk Zickermann" <[EMAIL PROTECTED]>
Subject: Re: [Matplotlib-users] matplotlib - representation of nan
    values in    2D
To: Matplotlib-users@lists.sourceforge.net
Message-ID:
    <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Dear  all,
thanks for your help. this is what I was looking for!
Dirk


2007/9/26, Eric Firing <[EMAIL PROTECTED]>:
>
> David Huard wrote:
> > Hi Dirk,
> >
> > If you haven't already done so, look at the numpy.ma <http://numpy.ma/>
> > module. It provides a masked array object that
 deals gracefully with
> > missing values. To the best of my knowledge, most matplotlib functions
> > understand masked arrays and deal with it accordingly, exception made of
> > those requiring a full matrix (such as contour). Take a look at
>
> contour handles masked arrays correctly, as far as I know; contourf has
> some bugs in its masked array handling, but depending on the type and
> distribution of voids, it may still be good enough.
>
> pcolor and image have no problems with masked arrays.
>
> Eric
>
> > examples/image_masked.py. Also, in the Basemap toolkit, there is at
> > least one example showing how to plot a masked array on a map.
> >
> > Cheers,
> >
> > David
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
>
 Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


End of Matplotlib-users Digest, Vol 16, Issue 32
************************************************








      
____________________________________________________________________________________
¡Sé un mejor asador!
Aprende todo sobre asados.                      
http://telemundo.yahoo.com/promos/mejorasador.html
#!/usr/bin/env python

# This example demonstrates how to use a constraint polygon in
# Delaunay triangulation.

from scipy import*
from pylab import*

read_file= open ('W:/Serio/necfile.out','r')

L =read_file.readlines()
                
fieldlist =[]
f = 0
for line in L:
        f=f+1
        if 'NEAR ELECTRIC FIELDS'in line:

                rpoints = 3
                phipoints = 3
                tetapoints = 1
                
                for line in range (f+3,f+4+rpoints*phipoints*tetapoints):
                        fieldlist.append(L[line])
                        
Ex = [];Ey = [];Ez = []
x1 =[];y1=[];z1=[]
Exphase=[]; Eyphase=[]; Ezphase=[]
                
for i in range(len(fieldlist)-1):
       
        splitlines= fieldlist[i].split()
        
        x1.append(float(splitlines[0]))     #here we pick up the x,y,x coordinates of the points
        y1.append(float(splitlines[1]))     #where the manitude has been calculated
        z1.append(float(splitlines[2]))

        Ex.append(float(splitlines[3]))     #pick up the e-filed magnitudes
        Ey.append(float(splitlines[5]))     #u append as floats instead os string for later calculations
        Ez.append(float(splitlines[7]))

        Exphase.append(float(splitlines[4])) # pick up the phases just in case they are needed
        Eyphase.append(float(splitlines[6]))
        Ezphase.append(float(splitlines[8]))
read_file.close()        
                

# i want to see if i can calculate the magnitude of the electric field

E_field_Mag = []
for i in range(len(Ex)):
    E_Magnitude = sqrt((Ex[i])**2 + (Ey[i])**2+(Ez[i])**2)
    E_field_Mag.append(E_Magnitude)
    
#E_field_Mag = array(E_field_Mag)

#y values are  zero
#X,Z = meshgrid(x1, z1)

pcolor(x1,y1,E_field_Mag)





-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to