[Matplotlib-users] basemap covering a small area

2007-07-06 Thread Jesper Larsen
Hi matplotlib users,

I am interested in making basemap plots covering only a small area. When I do 
this the meridians and parallels (and labelling of these) look strange. I 
have pasted in a simple example below showing the problem (at least on my 
computer):

import pylab
from matplotlib.toolkits import basemap

bmap = basemap.Basemap(120.33, 35.95, 120.55, 36.12)
merid = [120.3, 120.35, 120.4, 120.45, 120.5, 120.55, 120.6]
paral = [35.94, 35.96, 35.98, 36.0, 36.02, 36.04, 36.06, 36.08, 36.1, 36.12, 
36.14]
bmap.drawparallels(paral, labels=[1,0,0,0])
bmap.drawmeridians(merid, labels=[0,0,0,1])
pylab.savefig('test.png')

Regards,
Jesper

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem with linear plot after semilog plot

2007-07-06 Thread Lorenzo Isella
Dear All,
I am a bit puzzled at an unusual problem I am experiencing.
Fundamentally, I call a couple of functions and I plot some data.
First, I create a semilog plot using pylab.semilogx, then I make a
normal linear plot.
But, in the second case I get an error message:

Traceback (most recent call last):
  File "./air-mean-free-path.py", line 206, in ?
pylab.plot((diam_seq*1e9),K_bis,linewidth=2.)
  File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line
2027, in plot
ret =  gca().plot(*args, **kwargs)
  File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 2131, in plot
self.autoscale_view(scalex=scalex, scaley=scaley)
  File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line
985, in autoscale_view
self.set_xlim(XL)
  File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line
1220, in set_xlim
raise ValueError('Cannot set nonpositive limits with log transform')
ValueError: Cannot set nonpositive limits with log transform


Which seems to be dealing with a semilog plot again, but that is no
longer the case.
What is going on? I am using the pylab.hold(False) command at the end
of each plot in order not to mess everything up.
Below there is the code producing the bug. If I go, after the 1st
semilog plot, for another semilog plot, everything is fine and no
error is generated.




K_thermo=K_talbot_test(T,knudsen,Ra)

pylab.semilogx(knudsen,K_thermo,linewidth=2.)
pylab.xlabel('knudsen number',fontsize=20.)
pylab.ylabel('K_th',fontsize=20.)
pylab.title('Thermophoretic coefficient',fontsize=20.)
pylab.grid(True)
pylab.savefig('thermophoretic_coefficient')

pylab.hold(False)



diam_seq=pylab.load("diameter_sequence")

diam_seq=diam_seq/1e9

print 'the shape of diam_seq is', shape(diam_seq)



K_bis=K_talbot(T)

print 'the shape of k_bis is', shape(K_bis)

#pylab.semilogx((diam_seq*1e9),K_bis,linewidth=2.)
pylab.plot((diam_seq*1e9),K_bis,linewidth=2.)
# with the plot command I run into trouble, with semilogx everything
is fine instead.

pylab.xlabel('diameter [nm]',fontsize=20.)
pylab.ylabel('K_th',fontsize=20.)
#pylab.legend(('prey population','predator population'))
pylab.title('Thermophoretic coefficient at T=350K',fontsize=20.)
pylab.grid(True)
pylab.savefig('thermophoretic_coefficient_vs_particle_diameter')

pylab.hold(False)

Does anybody have a clue at what is going on? I am sure it must be
something quick to fix.
Many thanks

Lorenzo

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Steve Schmerler
kaushik.ghose wrote:

> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')
> 
> matplotlib renders it fine, but won't save it to svg correctly - the 
> summation symbol doesn't show up.
> 
> Is this a configuration issue on my part, or is svg support for latex 
> currently incomplete?

AFAIK, the latex support for the SVG backend isn't fully working yet. 
For rcParams['text.usetex']=True you'll get an error. With 
rcParams['text.usetex']=False I get the same issue that you see (Sum 
symbol missing when I open the .svg in Inkscape).

See also 
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg03340.html

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Segmentation fault with import pylab statement

2007-07-06 Thread Achim Gaedke
Hi!

This little prorgram (it accidentially came to my keyboard) results in a
segmentation fault:

# start
import numpy
import pylab
pulsewidth=3e-6
t_array=(numpy.arange(2048, dtype=numpy.float32)-1024)*90e-9
sinc_array=numpy.array((len(t_array),),dtype=numpy.float32)
sinc_array[:]=1e-6
sinc_array[numpy.abs(t_array)<(pulsewidth/2)]=1.0
# end

I do not use pylab. Just remove the "import pylab" statement and the
program exits without any fault.

The machine is a i686 with Debian testing distribution. The version
numbers are

python-matplotlib0.90.0-1
python-matplotlib-data   0.90.0-1
python-matplotlib-doc0.90.0-1

and

python-numpy 1:1.0.3-1
python-numpy-dev 1:1.0.3-1
python-numpy-doc 1:1.0.3-1
python-numpy-ext 1:1.0.3-1

Does anyone have similar problems?

Yours, Achim

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap covering a small area

2007-07-06 Thread Jeff Whitaker
Jesper Larsen wrote:
> Hi matplotlib users,
>
> I am interested in making basemap plots covering only a small area. When I do 
> this the meridians and parallels (and labelling of these) look strange. I 
> have pasted in a simple example below showing the problem (at least on my 
> computer):
>
> import pylab
> from matplotlib.toolkits import basemap
>
> bmap = basemap.Basemap(120.33, 35.95, 120.55, 36.12)
> merid = [120.3, 120.35, 120.4, 120.45, 120.5, 120.55, 120.6]
> paral = [35.94, 35.96, 35.98, 36.0, 36.02, 36.04, 36.06, 36.08, 36.1, 36.12, 
> 36.14]
> bmap.drawparallels(paral, labels=[1,0,0,0])
> bmap.drawmeridians(merid, labels=[0,0,0,1])
> pylab.savefig('test.png')
>
> Regards,
> Jesper
>   
Jesper:  Hmm, I guess I never thought anyone would make a map that small.  I 
tweaked some of the parameters to make it work better (svn revision 3470).  
Here's the diff in case you just want to apply the patch manually:

===
--- basemap.py  (revision 3469)
+++ basemap.py  (working copy)
@@ -1665,9 +1665,9 @@
 xoffset = (self.urcrnrx-self.llcrnrx)/100.
 
 if self.projection in ['merc','cyl','mill','moll','robin','sinu']:
-lons = 
NX.arange(self.llcrnrlon,self.urcrnrlon+0.1,0.1).astype(NX.Float32)
+lons = NX.arange(self.llcrnrlon,self.urcrnrlon+0.01,0.01)
 else:
-lons = NX.arange(0,360.1,0.1).astype(NX.Float32)
+lons = NX.arange(0,360.01,0.01)
 # make sure latmax degree parallel is drawn if projection not merc or 
cyl or miller
 try:
 circlesl = circles.tolist()
@@ -1729,7 +1729,7 @@
 # search along edges of map to see if parallels intersect.
 # if so, find x,y location of intersection and draw a label there.
 if self.projection == 'cyl':
-dx = 0.01; dy = 0.01
+dx = 0.001; dy = 0.001
 else:
 dx = 1000; dy = 1000
 if self.projection in ['moll','robin','sinu']:
@@ -1883,11 +1883,11 @@
 xoffset = (self.urcrnrx-self.llcrnrx)/100.
 
 if self.projection not in ['merc','cyl','mill','moll','robin','sinu']:
-lats = NX.arange(-latmax,latmax+0.1,0.1).astype(NX.Float32)
+lats = NX.arange(-latmax,latmax+0.01,0.01)
 else:
-lats = NX.arange(-90,90.1,0.1).astype(NX.Float32)
-xdelta = 0.1*(self.xmax-self.xmin)
-ydelta = 0.1*(self.ymax-self.ymin)
+lats = NX.arange(-90,90.01,0.01)
+xdelta = 0.01*(self.xmax-self.xmin)
+ydelta = 0.01*(self.ymax-self.ymin)
 for merid in meridians:
 lons = merid*NX.ones(len(lats),NX.Float32)
 x,y = self(lons,lats)
@@ -1941,7 +1941,7 @@
 # search along edges of map to see if parallels intersect.
 # if so, find x,y location of intersection and draw a label there.
 if self.projection == 'cyl':
-dx = 0.01; dy = 0.01
+dx = 0.001; dy = 0.001
 else:
 dx = 1000; dy = 1000
 if self.projection in ['moll','sinu','robin']:

This will make drawing of meridians and parallels slower, however.

-Jeff

-- 
Jeffrey S. Whitaker Phone  : (303)497-6313
Meteorologist   FAX: (303)497-6449
NOAA/OAR/PSD  R/PSD1Email  : [EMAIL PROTECTED]
325 BroadwayOffice : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Edin Salkovic
Hi kaushik,

On 7/6/07, kaushik.ghose <[EMAIL PROTECTED]> wrote:
> Hi,
>
> When I do
>
> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')

Shouldn't that be:
r'$\sum_{n=1}^{100}$'   # i.e. a "raw" string.

or:

'$\\sum_{n=1}^{100}$'  # Escaped backslash

Does this help?

Cheers,
Edin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Steve Schmerler
Edin Salkovic wrote:
> Hi kaushik,
> 
> On 7/6/07, kaushik.ghose <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> When I do
>>
>> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')
> 
> Shouldn't that be:
> r'$\sum_{n=1}^{100}$'   # i.e. a "raw" string.
> 
> or:
> 
> '$\\sum_{n=1}^{100}$'  # Escaped backslash
> 

>From my experience, with usetex True and without r'', the TeX string is parsed
correctly even for stuff like text(0,0,'$\sum_{n=1}^{100}$ with $\Omega$'), i.e.
mathmode and textmode combined.

Here, indeed, with usetex False, using r'' produces the \sum sign in the .svg 
but
"n=1" and "100" are not alinged correctly (they both appear above \sum). With 
usetex
True there is the NotImplementedError (mpl 0.90.0dev3131).

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. -- 
Douglas Adams


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Exclude top and right lines from a plot frame

2007-07-06 Thread Pecevski Dejan
Hi,

Is there some convenient way to setup a frame in axes which only has the 
bottom and left lines?

I've tried some workaround solution like this:
a = subplot(211)
a.set_frame_on(False)
a.hlines(ymin,xmin,xmax)
a.vlines(xmin,ymin,ymax)

Is there a more appropriate  solution?

thanks,
Dejan

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Kaushik Ghose
Hi Edin,

Edin Salkovic wrote:
>>
>> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')
> 
> Shouldn't that be:
> r'$\sum_{n=1}^{100}$'   # i.e. a "raw" string.
> 
> or:
> 
> '$\\sum_{n=1}^{100}$'  # Escaped backslash
> 

Actually the original string renders as desired. Its the svg save that 
causes the problem.

I gather this is due to incomplete implementation of svg export.

thanks!
-Kaushik


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Edin Salkovic
On 7/6/07, Kaushik Ghose <[EMAIL PROTECTED]> wrote:
> Hi Edin,
>
> Edin Salkovic wrote:
> >>
> >> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')
> >
> > Shouldn't that be:
> > r'$\sum_{n=1}^{100}$'   # i.e. a "raw" string.
> >
> > or:
> >
> > '$\\sum_{n=1}^{100}$'  # Escaped backslash
> >
>
> Actually the original string renders as desired. Its the svg save that
> causes the problem.
>
> I gather this is due to incomplete implementation of svg export.
>
> thanks!
> -Kaushik

Sorry, I see the problem now.  Unfortunately I wont have the resources
to investigate into this this weekend.  It's past midnight here, and
tomorrow early I have to travel.

Best,
Edin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] problems when zooming in to the pixel level

2007-07-06 Thread Rein van den Boomgaard
Dear All,

i'm displaying an image (cmap = gray, interpolation = nearest: i want to
see the pixels) and i plot point (markers) on top of the image. These
markers are calculated at the subpixel level so i want to zoom in to see
whether they are placed correctly.

When zooming in i notice two things:

1. at certain zoomlevels the image disappears (i do see the markers). At
other zoomlevels i see a tremendous change in brightness of the image.
Especcially at high zoomlevels i see this behaviour

2. when i zoom in a lot (selecting rectangle all over), the display gets
slower and slower... In the end, when viewing about 5x5 pixels or so it
becomes too slow...

Any ideas? I would love to use matplotlib (i really like it) but it
seems to have performance problems when displaying images is your main
concern.


Regards
Rein van den Boomgaard

(if needed i could send a zip file with programs and data)




-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users