Re: [Matplotlib-users] Reducing png file size

2009-05-17 Thread Jouni K . Seppänen
Jesper Larsen  writes:

> Unfortunately the files are quite big (up to ~300 kb). I have however
> tried using the Linux tool pngnq to reduce the file size with a factor
> ~3-4 with almost no degradation of the result.

>   Pixel depth (Pixel Depth): 32
>   Colour Type (Photometric Interpretation): RGB with alpha channel

>   Pixel depth (Pixel Depth): 8
>   Colour Type (Photometric Interpretation): PALETTED COLOUR (256
> colours, 0 transparent)

This means pngnq has quantized the original RGBA image with 8 bits per
channel to an image with a 256-color palette. I don't think Agg has any
support for rendering directly to a paletted image, so to achieve
similar results, you would have to do the quantization in a separate
pass anyway.

> I am not using transparency for anything. For a web application a
> reduction from 300 kb to 90 kb is really important so I hope you have
> some good ideas.

A web application needs to be fast, right? According to its home page,
pngnq "is limited mostly to off-line uses rather than real time image
delivery". You could take a look at PIL to see if it has any fast
quantization algorithms, and pass your result to it as in the
to_numeric.py example (see also webapp_demo.py for how to avoid using
the pylab machinery for figure management). If not, you could always
implement some fast quantization algorithm in numpy:

http://en.wikipedia.org/wiki/Color_quantization

My guess is that if you always produce similar-looking images, you could
fix the palette off-line using whatever fancy algorithm you like, and
then the actual conversion could be done pretty fast, especially if you
can forgo dithering - perhaps for many types of charts it is not
necessary.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot

2009-05-17 Thread Jae-Joon Lee
On Sun, May 17, 2009 at 5:03 PM, Alan G Isaac  wrote:
> So I am suggesting that any new functions
> certainly should not propagate this anomaly.

Understood. And, yes, I guess you're quite right in this regard.
And I'll try to deprecate the current matlab-like interface in future
(at least in my axes_grid toolkit).

Thanks,

-JJ

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Question about imshow

2009-05-17 Thread Jae-Joon Lee
>
> I think the point here is that
>
>        img = Image('foo.png')
>        imshow(img)
>
> and
>
>        img = Image('foo.png')
>        imshow(asarray(img))
>
> give different results, since matplotlib.image.pil_to_array functions
> differently from what PIL exposes in __array_interface__
>
> --
> Pauli Virtanen
>
>

I see. Thanks for clarifying this. And yes, I think this should be fixed.

Hmm, it seems that somehow pil_to_array tries to make the image
upside-down by itself.

x_str = im.tostring('raw',im.mode,0,-1)

However. I'm afraid that changing this behavior may not be ideal for
backward-compatibility.

I think one possible solution would be to simply deprecate the support
for PIL image in imshow, and let users explicitly use array-interface
via asarray function.

Is there any other idea?
I'll make this change unless someone come up with something.

-JJ

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot

2009-05-17 Thread Jae-Joon Lee
Hi all,

I had a few off-list conversation with Alan, and I'm also quite agree
with him for this issue.
Just to rephrase, I think the current subplot interface has (at least)
two issues.

 issue 1)  the indexing convention is not that of python. The index
starts from 1, instead of 0. (eg "111")

 issue 2)  It is not easy (actually impossible) to make an axes
spanning multiple cells.

While I think we need to keep the current interface at least for a
while, it would be better if we come up with some pythonic interface
that may eventually replace the current matlab-centric one.

So, how other developers and users think about this?


And here are a few options that has been suggested.


Option 1)  use of "origin" keyword.

  ex) subplot(2, 2, 0, origin=0)

  Ryan is -1 for this and so am I.

  It also does not address the issue 2.


Option 2) Introduce a new command

   ex1) ax = fig.subplot2grid(shape=(3,3), loc=(0,0), rowspan=2, colspan=2)

  Instead of simple subplot(111), we may do something like

   ex2) ax = fig.subplot2grid((1,1), 0)


Option 3) introduce a new class for grid specification and modify
subplot to accept this.

   One idea I have is to use an array-like interface.

ex1) ax = fig.subplot(grid_spec(3,3)[0:2,0:2])

   For subplot(111) equivalent,

ex2) ax = fig.subplot(grid_spec(1,1)[0])

I, personally, want to reuse the convention in my axes_grid toolkit,
where it would be better if this grid specification(?) can be
expressed as a single argument. And I'm +1 for option 3 for this
reason. However, I'm afraid that option 3 is not expressive enough.

Of course, we should explore other solutions and any suggestions will
be welcomed.

So, how others think?

Regards,

-JJ



On Fri, May 15, 2009 at 1:41 PM, Alan G Isaac  wrote:
> I love Matplotlib.
>
> That said, I find the indexing subplots to be an annoyance,
> because it uses MATLAB conventions rather than Python
> conventions for indexing.  I think moving this convention
> into the OO API was a mistake.
>
> Since Matplotlib is not yet 1.0,
> I am suggesting that this be "fixed".
> I understand this will cause some pain.
>
> If it cannot be fixed due to code breakage,
> how about an "origin" keyword, that can be 0 or 1?
>
> Cheers,
> Alan Isaac
>
>
> --
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Reducing png file size

2009-05-17 Thread Jesper Larsen
Hi mpl-users,

I have a web application in which I produce png files using
matplotlib. Unfortunately the files are quite big (up to ~300 kb). I
have however tried using the Linux tool pngnq to reduce the file size
with a factor ~3-4 with almost no degradation of the result. I
therefore wondered whether it is possible to setup matplotlib to do
something similar (from the source code the savefig method for png
files does not seem to use any keyword arguments). Here is the output
of the command pnginfo for the matplotlib output file and the pngnq
processed file:

0.0.0.0.0.0.20090517t00z.768.png...
  Image Width: 768 Image Length: 328
  Bitdepth (Bits/Sample): 8
  Channels (Samples/Pixel): 4
  Pixel depth (Pixel Depth): 32
  Colour Type (Photometric Interpretation): RGB with alpha channel
  Image filter: Single row per byte filter
  Interlacing: No interlacing
  Compression Scheme: Deflate method 8, 32k window
  Resolution: 5039, 5039 (pixels per meter)
  FillOrder: msb-to-lsb
  Byte Order: Network (Big Endian)
  Number of text strings: 0 of 0
  Offsets: 0, 0

0.0.0.0.0.0.20090517t00z.768-nq8.png...
  Image Width: 768 Image Length: 328
  Bitdepth (Bits/Sample): 8
  Channels (Samples/Pixel): 1
  Pixel depth (Pixel Depth): 8
  Colour Type (Photometric Interpretation): PALETTED COLOUR (256
colours, 0 transparent)
  Image filter: Single row per byte filter
  Interlacing: No interlacing
  Compression Scheme: Deflate method 8, 32k window
  Resolution: 0, 0 (unit unknown)
  FillOrder: msb-to-lsb
  Byte Order: Network (Big Endian)
  Number of text strings: 0 of 0
  Offsets: 0, 0

I am not using transparency for anything. For a web application a
reduction from 300 kb to 90 kb is really important so I hope you have
some good ideas. Otherwise I guess I will have to put in a call to
pngnq in my code (although I prefer to avoid calls to external
programs in the Python code when possible).

Best regards,
Jesper

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot

2009-05-17 Thread Alan G Isaac
On 5/17/2009 2:44 PM Jae-Joon Lee apparently wrote:
> I meant consistency with Matplotlib itself.

My point is that that is not well defined,
since most of the OO API in Matplotlib is
Python centric, but the subplot definition
is an exception.

So I am suggesting that any new functions
certainly should not propagate this anomaly.

 > I agree and I'm personally for python-centric interface throughout 
 > matplotlib.
 > I think what we need is to devise a new python-centric interface
 > (e.g., subplot2grid you suggested) and may try to deprecate subplot
 > eventually.

So, looking forward, keeping that anomaly isolated
will be important, so that changes do not need to
be made in additional locations. (Or so I claim...)

Cheers,
Alan Isaac


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] A request for code critique

2009-05-17 Thread Gökhan SEVER
Hmm,

Is it working on your side from a bash shell as "ipython --pylab script
argument"

I couldn't make it work in this fashion. As I said whos list nothing :(

I am on Fedora 10 x86, Python 2.5.2, IPython 0.10.bzr.r1173

Without the pylab switch I see the interactive space with variables. I also
have plot imported from my script, however each time I have to call show()
to see the figure to be re-drawn.

To me, it seems one need to compromise: either to start ipython --pylab
first and call scripts using "run" magic command or like you suggested start
ipython with the script loaded and call show() after each plot command.

Please comment me if I am wrong...

Gökhan


On Sun, May 17, 2009 at 3:19 PM, Roy Hyunjin Han <
starsareblueandfara...@gmail.com> wrote:

> On Sun, May 17, 2009 at 2:17 PM, Gökhan SEVER 
> wrote:
> > Hello Roy,
> >
> > "ipython splot.py 09_03_23_11_44_54.stats.tas"
> >
> > works, but I can't make it work with pylab switch. It executes my script,
> > however whos list an empty namespace :(
>
> Gökhan,
>
> The "whos" command works for me.
>
> Also, why can't you use "import pylab" and make your plots directly in
> ipython?
> You can also use "from pylab import *" if you don't want to type pylab
> every time.
>
> In [1]: whos
> Variable   TypeData/Info
> 
> argv   list['splot.py',
> '09_03_23_11_44_54.stats.tas']
> argv_arr   ndarray 12x13: 156 elems, type
> `float64`, 1248 bytes
> axes   function
> axis   function
> boxplotfunction
> d09_03_23_11_44_54_stats_tas   ndarray 12x13: 156 elems, type
> `float64`, 1248 bytes
> data_len   int 12
> draw   function
> f  file '09_03_23_11<...>', mode 'r' at 0x88ef260>
> i  int 11
> loadtxtfunction
> mouse_hover_formatxfunction mouse_hover_formatx at 0x88e84fc>
> mouse_hover_formatyfunction mouse_hover_formaty at 0x88e84c4>
> plot   function
> savefigfunction
> show   function
> skiprows   int 30
>
--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] A request for code critique

2009-05-17 Thread Roy Hyunjin Han
On Sun, May 17, 2009 at 2:17 PM, Gökhan SEVER  wrote:
> Hello Roy,
>
> "ipython splot.py 09_03_23_11_44_54.stats.tas"
>
> works, but I can't make it work with pylab switch. It executes my script,
> however whos list an empty namespace :(

Gökhan,

The "whos" command works for me.

Also, why can't you use "import pylab" and make your plots directly in ipython?
You can also use "from pylab import *" if you don't want to type pylab
every time.

In [1]: whos
Variable   TypeData/Info

argv   list['splot.py',
'09_03_23_11_44_54.stats.tas']
argv_arr   ndarray 12x13: 156 elems, type
`float64`, 1248 bytes
axes   function
axis   function
boxplotfunction
d09_03_23_11_44_54_stats_tas   ndarray 12x13: 156 elems, type
`float64`, 1248 bytes
data_len   int 12
draw   function
f  file', mode 'r' at 0x88ef260>
i  int 11
loadtxtfunction
mouse_hover_formatxfunction
mouse_hover_formatyfunction
plot   function
savefigfunction
show   function
skiprows   int 30

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot

2009-05-17 Thread Jae-Joon Lee
> Oops, sorry about that.  Looks like I have it fixed now.
>
> JDH
>


Yes, it looks fine now.
Thanks!

-JJ

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] polar plot: problem with negative angles

2009-05-17 Thread Magnus Benjes
> Magnus Benjes wrote:
>> Hello,
>> in version 0.98.5.2 the polar plot still has a problem with negativ 
>> angles.
>> The polarplot is drawing a circle when the angle changes from negativ to 
>> positiv (e.g. from -0.01 to +0.01).
>
> Your example works fine with svn.  I don't recall whether the problem was 
> fixed before the last release.  I think it was.
>
Thank you for the hint, in version 0.98.6 the polar plot has no problems 
with negativ angles any more.
But now there are only gridlines in radial direction and the gridlines in 
angular direction are missing.

Magnus 


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] A request for code critique

2009-05-17 Thread Gökhan SEVER
Hello Roy,

"ipython splot.py 09_03_23_11_44_54.stats.tas"

works, but I can't make it work with pylab switch. It executes my script,
however whos list an empty namespace :(

My aim of loading the variables and results into an interactive pylab
enabled workspace is to be able to continue working on the same data and if
necessary make some manipulations like adding titles, labels, legends,
changing scales depends on a person's need.

According to IPython documentation it is also possible to make IPython as
the default python environment. (
http://ipython.scipy.org/doc/nightly/html/interactive/reference.html#ipython-as-your-default-python-environment)
And again no way of starting with pylab ("there is no way to pass IPython
any command-line options")

Any other ideas?

Btw, I haven't seen a blue star lately :)

Gökhan


On Sun, May 17, 2009 at 7:07 AM, Roy Hyunjin Han <
starsareblueandfara...@gmail.com> wrote:

> On Sat, May 16, 2009 at 4:34 PM, Gökhan SEVER 
> wrote:
> >>> However I still couldn't figure out how to drop in ipython from the
> bash shell call
> >>> while all my variable context visible in the ipython namespace.
>
>
> Gökhan,
>
> Have you tried the following?
>
> RHH
>
>
> $ ipython splot.py 09_03_23_11_44_54.stats.tas
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.8.4 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help  -> Python's own help system.
> object?   -> Details about 'object'. ?object also works, ?? prints more.
>
> In [1]: skiprows
> Out[1]: 30
>
--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] polar plot: problem with negative angles

2009-05-17 Thread Eric Firing
Magnus Benjes wrote:
> Hello,
> in version 0.98.5.2 the polar plot still has a problem with negativ angles.
> The polarplot is drawing a circle when the angle changes from negativ to 
> positiv (e.g. from -0.01 to +0.01).

Your example works fine with svn.  I don't recall whether the problem 
was fixed before the last release.  I think it was.

>  
> But in "What new in 0.98.4" 
> (http://matplotlib.sourceforge.net/users/whats_new.html) I can read:
> "Fix polar interpolation to handle negative values of theta - MGD"
I think that commit actually introduced the problem.

>  
> Is there a workaround for this problem?

A release appears to be imminent--it was tagged hours ago.  Can you 
update when it appears?

Eric


>  
> Regards
> Magnus
>  
> 
> import numpy as np
> import matplotlib
> import matplotlib.pyplot as plt
>  
> x = np.linspace(-np.pi/3, np.pi/3, 100)
> y = np.sin((10*x)**2)+2
>  
> plt.subplot(111, polar=True)
> plt.plot(x,y)
> plt.title(matplotlib.__version__)
> plt.show()
> 
>  
> 
> 
> 
> 
> --
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables 
> unlimited royalty-free distribution of the report engine 
> for externally facing server and web deployment. 
> http://p.sf.net/sfu/businessobjects
> 
> 
> 
> 
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colormap using (UV)coordinates from file

2009-05-17 Thread Alan G Isaac
On 5/17/2009 11:11 AM Linda_swe apparently wrote:
> ("total size of  new array must be unchanged")

Again, this means what it says.
Your data array is the wrong size.
You cannot for example reshape a (3,) array into a (2,2) array.

http://www.scipy.org/Numpy_Example_List_With_Doc#head-11717acafb821da646a8db6997e59b820ac8761a

You can contour any 2d array.
You can optionally supply 1d coordinates.

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.contourf

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> plt.contour(np.add.outer(np.arange(20),np.arange(20)))

>>> plt.show()

Alan Isaac


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colormap using (UV)coordinates from file

2009-05-17 Thread Linda_swe

Hi Alan,


Thanks and it works for y and x but i guess i dont know how to shapet Z
("total size of  new array must be unchanged")

Overall i just dont get it how to calcuate the nlons and nlats fro Z.


yre = np.reshape(lats,nlats) 
xre = np.reshape(lons,nlons) 

print yre
print xre

zre = np.reshape(values,(nlats,nlons)).transpose() 
CT = plt.contourf(xre, yre, zre,58,cmap=plt.cm.jet)

cbar = plt.colorbar()


plt.show()





AlanIsaac wrote:
> 
> On 5/17/2009 10:21 AM Linda_swe apparently wrote:
>> atlest give me a hint...
> 
> The hint:
> 
>> error:list object has no attribute reshape
> 
> Listen to Python: all the info is there.
> A list is not a numpy array.
> Don't treat it like one.
> 
> However you can do:
> numpy.reshape(mylist, myshape)
> 
> Alan Isaac
> 
> --
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables 
> unlimited royalty-free distribution of the report engine 
> for externally facing server and web deployment. 
> http://p.sf.net/sfu/businessobjects
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Colormap-using-%28UV%29coordinates-from-file-tp23572972p23584266.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colormap using (UV)coordinates from file

2009-05-17 Thread Alan G Isaac
On 5/17/2009 10:21 AM Linda_swe apparently wrote:
> atlest give me a hint...

The hint:

> error:list object has no attribute reshape

Listen to Python: all the info is there.
A list is not a numpy array.
Don't treat it like one.

However you can do:
numpy.reshape(mylist, myshape)

Alan Isaac

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colormap using (UV)coordinates from file

2009-05-17 Thread Linda_swe

Why dont anyone answer me???

atlest give me a hint...

Ok, so i want to use the my csv as input and then plot the contour. I have
the follwing code but gives

error:list object has no attribute reshape

is using list diffrent than using numpys loadtext and then into variables
???


from matplotlib.mlab import load
import matplotlib.pyplot as plt 
import numpy as np
import csv

portfolio = csv.reader(open("file.csv", "rb"))
portfolio_list = []
portfolio_list.extend(portfolio)
lats = []
lons = []
values=[]

for data in portfolio_list:
lats.append(data[0])
lons.append(data[1])
values.append(data[2])
print lats
print lons


nlats = len(lats)
nlons = len(lons)

yre = lats.reshape(nlats,nlons)
xre = lons.reshape(nlats,nlons)
zre = values.reshape(nlats,nlons)
 later in the defined map
CT = plt.contourf(xre, yre, zre, cmap=color_map)

cbar = plt.colorbar()


plt.show()

-- 
View this message in context: 
http://www.nabble.com/Colormap-using-%28UV%29coordinates-from-file-tp23572972p23583803.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot

2009-05-17 Thread John Hunter
On Sat, May 16, 2009 at 10:58 PM, Jae-Joon Lee  wrote:

>>  http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#rgb-axes
>
> Thanks a lot, John.
> However, example figures are missing currently. (instead it shows a
> message "Exception occurred rendering plot.").
> Also, API documentations are not correctly generated also. My quick
> guess is that the axes_grid module was not found during the sphinx
> run. Can you take a look? The documentation builds fine for me.

Oops, sorry about that.  Looks like I have it fixed now.

JDH

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Question about imshow

2009-05-17 Thread Pauli Virtanen
Sun, 17 May 2009 00:15:48 -0400, Jae-Joon Lee wrote:

> On Sat, May 16, 2009 at 6:58 PM, 
>  wrote:
>>
>> Hi,
>> I want to read images and do some processing with them. While learning
>> how to do this, i.e. opening images, displaying them, transforming them
>> tu numpy arrays, etc., I came across a strange behaviour. If I open an
>> image and use imshow() to display it, it comes upside down. See this
>> thread in the numpy mailing list for more details:
>> http://thread.gmane.org/gmane.comp.python.numeric.general/30148 .
>> Someone on that list suggested to check here if this behavior was
>> correct. Is it normal that the image appears upside down? If yes, can
>> someone explain what's going on?
> 
> Note that the image may be upside down for you but may be correct for
> others. The array itself does not know about the orientation of the
> image and you have to explicitly specify this.

I think the point here is that

img = Image('foo.png')
imshow(img)

and

img = Image('foo.png')
imshow(asarray(img))

give different results, since matplotlib.image.pil_to_array functions 
differently from what PIL exposes in __array_interface__

-- 
Pauli Virtanen


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] A request for code critique

2009-05-17 Thread Gökhan SEVER
João,

Thank you for commenting on the code. sys.argv check is a wise one. Since I
was the only user of this little snippet I didn't give attention of this
detail, however eventually some other people will start using the code too.

I thought it is more efficient to only import functions that I use from
modules. This said, I don't see much speed difference on two codes. Is
import statement (or Python itself) intelligent enough to import only the
modules that are used inside a program or does it load all content at the
original import time?

Mouse-hover readings are really nice to have while analysing the data, and
ability of setting its sensitivity comes handier sometimes. I wish I could
find a way to put such a mechanism on my recent poster presentation. Hah,
maybe I should use a flexible lcd and let viewers to interract with the
poster themselves instead of viewing things on a dry big sheet of paper.

Yes, the IPython call from shell still stays a mystery...

Gökhan


On Thu, May 14, 2009 at 12:52 PM, João Luís Silva  wrote:

> Gökhan SEVER wrote:
>
>> Hello,
>>
>> After solving the boxplotting mystery, and figuring out how to change the
>> mouse hover reading sensitivities, I have finished my small script which
>> creates boxplots from a given file. I can call it either by issueing
>> ./splot.py file or from inside ipython -pylab with run command. However I
>> still couldn't figure out how to drop in ipython from the bash shell call
>> while all my variable context visible in the ipython namespace.
>>
>> I am attaching the script and a sample file I used. Could you please
>> comment whether I am on the right track? I am not very sure my locals() use
>> is correct to create a variable name from a given file name. There might be
>> other points that seem weaker in the code as well.
>>
>> Thank you.
>>
>> Gökhan
>>
>>
>>
> The code looks pretty good to me. I've done some minor style changes on the
> imports, and added an error check to see if the user passed a parameter or
> not. I didn't know how to change the mouseover format, this will be useful
> for me, thanks!
>
> I'm only a casual user of ipython, and I don't know how to do what you ask,
> so I'll leave that to someone else.
>
> (new splot.py attached)
>
> Best regards,
> João Silva
>
--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users