Re: [Matplotlib-users] Path lacks initial MOVETO

2012-01-23 Thread Bruno Santos
Sorry it took me a while to get back to you. I have finally written some
code to replicate the problem. I have attached a file with it.

Thank you very much in advance,
Bruno Santos

2012/1/19 Tony Yu 

>
>
> On Thu, Jan 19, 2012 at 12:07 PM, Bruno Santos wrote:
>
>> Hello everyone,
>>
>> I have been using matplotlib 0.99.3 to write some down. But I had to
>> upgrade my OS and so installed the last version of the library 1.1.0. But
>> unfortunately when I try to run my code I get the following error:
>>  raise ValueError, 'Path lacks initial MOVETO'
>> ValueError: Path lacks initial MOVETO
>>
>> I have been goggling it and saw some reports about it when using a vector
>> containing zeros for which I apply a log and then trying to plot this. But
>> the reports seem to indicate this was fixed in a svn version I can't access
>> anymore.
>> Can anyone point me on the correct direction to solve this problem?
>>
>> Thank you very much in advance,
>> Bruno Santos
>>
>> Could you provide a bit more information: Are you calling `Path`
> directly? If not, do you know what in your code is calling it? A minimal,
> runnable example would be very helpful.
>
> Cheers,
> -Tony
>
>
import numpy
from matplotlib.backends.backend_pdf import PdfPages
import pylab

class locus:
def __init__(self,nStartCoord,nEndCoord,nLength,nSize,zChr = 'None'):
"""
"""
self.nStartCoord = nStartCoord
self.nEndCoord = nEndCoord
self.zChr = zChr
self.aSCounts = numpy.zeros(nLength,dtype='Float64')
self.aASCounts = numpy.zeros(nLength,dtype='Float64')
self.nLength = nLength
self.nSize = nSize
self.pValue = 0.0
self.tMinIndex = (0,0)

def plot(self,display=False,all=True):
"""
self.plot(self,display=False,all=True)
all <- Flag can be used to plot the all locus or just the most significant part
Plot the number of signatures in the sense and anti sense 
strand for the current locus.
"""
#Plot sense strand
#Create a figure object
fig = pylab.figure(figsize=(16,9),dpi=160)
print 'ok1'
#Define Patch objects for the legend
#non_phase_pos = Patch(edgecolor='b', facecolor='b')
#phase_pos = Patch(edgecolor='r', facecolor='r')
#Plot title and legend for the figure
if all:
pylab.suptitle('%s:%d..%d with log p-value = %.2f' % (self.zChr,self.nStartCoord,self.nEndCoord,self.pValue),fontsize=24,x=0.39)
aSCounts = numpy.log(self.aSCounts[self.nSize:-self.nSize])
aASCounts = numpy.log(self.aASCounts[self.nSize:-self.nSize])
#get the first position in phase
nFirstPos = self.tMinIndex[0]-self.tMinIndex[0]/self.nSize*self.nSize
phasedIndex = numpy.arange(nFirstPos,len(aSCounts),self.nSize)
else:
pylab.suptitle('Most significant region on phased sRNA loci in %s:%d..%d with log p-value = %.2f' % (self.zChr,self.nStartCoord+self.tMinIndex[0],self.nStartCoord+self.tMinIndex[1],self.pValue),fontsize=18,x=0.45)
aSCounts  = numpy.log(self.aSCounts[self.tMinIndex[0]:self.tMinIndex[1]])
aASCounts = numpy.log(self.aASCounts[self.tMinIndex[0]:self.tMinIndex[1]])
phasedIndex = numpy.arange(0,len(aSCounts),self.nSize)
print 'ok3'
#pylab.figlegend([phase_pos,non_phase_pos],['Phased positions','Out of Phase positions'],'upper right',prop={'size':8})
#Produce the plot
pylab.subplot(211)
pylab.subplots_adjust(left=0.05, bottom=0.06, right=0.99, top=0.92, hspace=0.16)
pylab.xlabel('Relative position',fontsize= 14)
pylab.ylabel('Number of small RNAs',fontsize= 14)
pylab.bar(range(len(aSCounts)),aSCounts,color='b',width=1.0,edgecolor='b')
pylab.bar(phasedIndex,aSCounts[phasedIndex],color='r',width=2,edgecolor='r',alpha=1,align='center')
yaxis_pos = max(aSCounts)/3.0*2 #Compute the position where to place the markers of phased positions
try:#The sense strand may not contain any sRNA matching to it
pylab.scatter(phasedIndex, [yaxis_pos]*len(phasedIndex), marker='d', color='white',edgecolor='black')
except:pass
try:#The sense strand may not have any sRNA in phase
phasedIndexOccupied = phasedIndex[aSCounts[phasedIndex]>0]
pylab.scatter(phasedIndexOccupied, [yaxis_pos]*len(phasedIndexOccupied),s=40,marker='d',color='r',edgecolor='black')
except ValueError:pass 
#Plot anti sense strand
if all:
aASCounts = numpy.log(self.aASCounts[self.nSize:-self.nSize])
if (nFirstPos-3)>=0:phasedIndex = numpy.arange(nFirstPos-3,len(aASCounts),self.nSize)
else: phasedIndex = numpy.arange(nFirstPos+self.nSize-3,len(aASCounts),self.nSize)
else:
aASCounts = numpy.log(self.aASCounts[self.tMinIndex[0]:self.tMinIndex[1]])
pha

[Matplotlib-users] matplotlib for OSX 10.6, Python 2.7

2012-01-23 Thread Jason Sachs
Please post a binary .dmg or .egg file for matplotlib for OSX 10.6 and
Python 2.7.

There doesn't appear to be one on the downloads page; the closest I
could find for anything under OSX 10.6 was
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.3/
which only includes Python 2.6 support.

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] MQMQ: How to adjust the size and scale of the x-y axis of the graph.Thanks.

2012-01-23 Thread MQMQ

Dear all, 

Could you guys share your experience on:
How to adjust the size and scale of the x-y axis of the plot (e.g. how to
resize the "0 1 2" on x axis ), Thanks?
And special commands in matplotlib?

Thank you so much in advanced.
MQMQ
-- 
View this message in context: 
http://old.nabble.com/MQMQ%3A-How-to-adjust-the-size-and-scale-of-the-x-y-axis-of-the-graph.Thanks.-tp33177496p33177496.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Russ Dill
I'm using matplotlib from pylab to generate eye patterns for signal
simulations. My output pretty much looks like this:

http://www.flickr.com/photos/31208937@N06/6079131690/

Its pretty useful as it allows one to quickly see the size of the eye
opening, the maximum/minimum voltage, etc. I'd really like to be able
to create a heat diagram, like these:

http://www.lecroy.com/images/oscilloscope/series/waveexpert/opening-spread2_lg.jpg
http://www.lecroy.com/images/oscilloscope/series/waveexpert/opening-spread1_lg.jpg
http://www.iec.org/newsletter/august07_2/imgs/bb2_fig_1.gif
http://www.altera.com/devices/fpga/stratix-fpgas/stratix-ii/stratix-ii-gx/images/s2gx-rollout-6g-eye.jpg

Is there any way within matplotlib to do that right now?

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Path lacks initial MOVETO

2012-01-23 Thread Michael Droettboom

I have a solution for this in this pull request:

https://github.com/matplotlib/matplotlib/pull/684

If able, would you mind confirming that it addresses your issue?

Mike

On 01/23/2012 09:02 AM, Bruno Santos wrote:
Sorry it took me a while to get back to you. I have finally written 
some code to replicate the problem. I have attached a file with it.


Thank you very much in advance,
Bruno Santos

2012/1/19 Tony Yu mailto:[email protected]>>



On Thu, Jan 19, 2012 at 12:07 PM, Bruno Santos
mailto:[email protected]>> wrote:

Hello everyone,

I have been using matplotlib 0.99.3 to write some down. But I
had to upgrade my OS and so installed the last version of the
library 1.1.0. But unfortunately when I try to run my code I
get the following error:
 raise ValueError, 'Path lacks initial MOVETO'
ValueError: Path lacks initial MOVETO

I have been goggling it and saw some reports about it when
using a vector containing zeros for which I apply a log and
then trying to plot this. But the reports seem to indicate
this was fixed in a svn version I can't access anymore.
Can anyone point me on the correct direction to solve this
problem?

Thank you very much in advance,
Bruno Santos

Could you provide a bit more information: Are you calling `Path`
directly? If not, do you know what in your code is calling it? A
minimal, runnable example would be very helpful.

Cheers,
-Tony




--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2


___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MQMQ: How to adjust the size and scale of the x-y axis of the graph.Thanks.

2012-01-23 Thread Ethan Swint
On 1/20/2012 5:31 PM, MQMQ wrote:
> Dear all,
>
> Could you guys share your experience on:
> How to adjust the size and scale of the x-y axis of the plot (e.g. how to
> resize the "0 1 2" on x axis ), Thanks?
> And special commands in matplotlib?
>
> Thank you so much in advanced.
> MQMQ
You can change the font sizes for most of the plotting elements with the 
pyplot variable pyplot.rcParams.
Change the range of the XY axes by calling
pypolt.xlim(0,360)
pyplot.ylim(-0.01,4.05)
-or-
pyplot.axis(0,360,-0.01,4.05)
and you can adjust the ticmark values by
pyplot.xticks(range(360))

Also look into the pyplot.setp method.

-Ethan


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plotting contour in X-Z plane

2012-01-23 Thread Benjamin Root
On Thu, Jan 19, 2012 at 12:01 PM, Moore, Eric (NIH/NIDDK) [F] <
[email protected]> wrote:

> > -Original Message-
> > From: alw46 [mailto:[email protected]]
> > Sent: Thursday, January 19, 2012 11:31 AM
> > To: [email protected]
> > Subject: [Matplotlib-users] Plotting contour in X-Z plane
> >
> >
> > Hi All,
> >
> > I have a question similar to one posted on Aug 30, 2011 titled
> > "Plotting 2D
> > contourf in Axes3D X-Z plane instead of X-Y plane".  In fact, it is the
> > same
> > question, and I can't seem to find a satisfactory answer anywhere.
> >
> > I've attached an image of what I've done in the X-Y plane for
> > reference.
> > Like the other post, I'd like to do something similar to what I've done
> > in
> > the X-Y direction, but in the X-Z and Y-Z planes.  Since I've set up a
> > grid
> > of points throughout the space, this effectively allows me to take
> > "section
> > cuts" in different directions in the space.  But I can't seem to figure
> > out
> > how to do it.  I've switched around the "z-dir", as well as replacing X
> > and
> > Y with Z in ax.contourf.  For reference, I'm using matplotlib 1.1.0.
> >
> > I'm trying to achieve a similar affect to Mayavi's 'image_plane_widget'
> > to
> > take volume slices, but using matplotlib.
> >
> > http://old.nabble.com/file/p33168965/contours_xy.png
> > --
> > View this message in context: http://old.nabble.com/Plotting-contour-
> > in-X-Z-plane-tp33168965p33168965.html
> > Sent from the matplotlib - users mailing list archive at Nabble.com.
> >
>
> I've attached a function that I think does something similar to what you
> want, although without quite all of the bells and whistles you're looking
> for.  I'm sure there are better ways than just plotting so many lines, but
> it worked for quickly looking at some data for me.
>
> Eric
>
>
Eric,

That is a neat example.  Do you mind if I clean it up and include it in the
mpl gallary?

Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Path lacks initial MOVETO

2012-01-23 Thread Tony Yu
On Mon, Jan 23, 2012 at 9:56 AM, Michael Droettboom  wrote:

>  I have a solution for this in this pull request:
>
> https://github.com/matplotlib/matplotlib/pull/684
>
> If able, would you mind confirming that it addresses your issue?
>
> Mike
>
>
This fix worked on my system.
-Tony


>
> On 01/23/2012 09:02 AM, Bruno Santos wrote:
>
> Sorry it took me a while to get back to you. I have finally written some
> code to replicate the problem. I have attached a file with it.
>
>  Thank you very much in advance,
> Bruno Santos
>
>  2012/1/19 Tony Yu 
>
>>
>>
>>  On Thu, Jan 19, 2012 at 12:07 PM, Bruno Santos wrote:
>>
>>> Hello everyone,
>>>
>>>  I have been using matplotlib 0.99.3 to write some down. But I had to
>>> upgrade my OS and so installed the last version of the library 1.1.0. But
>>> unfortunately when I try to run my code I get the following error:
>>>  raise ValueError, 'Path lacks initial MOVETO'
>>> ValueError: Path lacks initial MOVETO
>>>
>>>  I have been goggling it and saw some reports about it when using a
>>> vector containing zeros for which I apply a log and then trying to plot
>>> this. But the reports seem to indicate this was fixed in a svn version I
>>> can't access anymore.
>>> Can anyone point me on the correct direction to solve this problem?
>>>
>>>  Thank you very much in advance,
>>>  Bruno Santos
>>>
>>>   Could you provide a bit more information: Are you calling `Path`
>> directly? If not, do you know what in your code is calling it? A minimal,
>> runnable example would be very helpful.
>>
>> Cheers,
>> -Tony
>>
>>
>
>
> --
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe 
> now!http://p.sf.net/sfu/learndevnow-dev2
>
>
>
> ___
> Matplotlib-users mailing 
> [email protected]://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> --
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Gousios George

Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:

Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 11:31 AM, Gousios George 
mailto:[email protected]>> wrote:


Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 9:07 AM, Gousios George
mailto:[email protected]>> wrote:

Hello , i have the following code in matlab and trying to do
it in
matplotlib.

I have this code in matlab (in a function showGraphs):
...
m = size(myList, 3);
for k = 1:m
g = myList(:, :, k);
image(g + 1)
axis off
axis square
M(k) = getframe;
end;

and in another file (another function):
...
M = showGraphs(grids)
movie(M, 1)



I did so far:

def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
for k in range(n):
mydata=data[:,:,k]
#plt.imshow(mydata+1)-->> this doesn't work

Also ,in order to do the animation :

grids=...(result from another function)
result=showGraph(grids)
fig=plt.figure()
ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
plt.show()

Right now the program says "TypeError: 'NoneType' object is not
callable" (it has errors in the animation call)

What should be my approach to this in order to have the
animation?

Thank you!


You're getting that error because the second argument to
FuncAnimation (`result` in your example) should be a function
(not always; see example 2 linked below). Right now, if your
`showGraphs` function is defined in full, it returns a value of
None, which gets saved to `result` (hence the error).

You should take a look at some of the image animation examples
(ex1
,
ex2
).

-Tony



I did now :


def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
ims=[]

for k in range(n):
mydata=data[:,:,k]
im=plt.imshow(mydata+1)
ims.append([im])
return ims

and now it gives me "TypeError: Invalid dimensions for image data.


Please post short, but executable examples when possible. I'm not 
sure what your data looks like, but your call to `sc.array` is 
strange (I'm not sure why you have square brackets, which effectively 
adds an unnecessary dimension to your data).


The code attached below should work.

Cheers,
-Tony

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import ArtistAnimation


fig = plt.figure()

def showGraphs(data):
data = np.asarray(data) # unnecessary in this example
n = np.shape(data)[2]

ims = []
#for mydata in np.rollaxis(data, -1):
for k in range(n):
mydata = data[:, :, k]
im = plt.imshow(mydata)
ims.append([im])
return ims

# 5 frames of a random 20 x 20 image
data = np.random.uniform(size=(20, 20, 5))
ims = showGraphs(data)

ani = ArtistAnimation(fig, ims)
plt.show()
Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't convert 
right the matlab code below?)
The data in the showGraphs function is the result from this function 
(in matlab):

.
grids = zeros(n, n, t + 1);
grids(:, :, 1) = rest;
for i = 2:(t + 1)
Extended = extendLat1(rest);
rest = applyExtended(Extended);
grids(:, :, i) = rest;
end;

And i did this in python:

   grids=sc.zeros((area,area,t+1))
rest=grids[:,:,0]
for i in range(1,t):
extended=extend(rest)
rest=apply_extend(extended)
grids[:,:,i]=rest
return grids

Thanks for helping!


Any help?Thanks!

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Tony Yu
2012/1/23 Gousios George 

> **
> Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:
>
> Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:
>
>
>
> On Sat, Jan 21, 2012 at 11:31 AM, Gousios George wrote:
>
>>  Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:
>>
>>
>>
>> On Sat, Jan 21, 2012 at 9:07 AM, Gousios George wrote:
>>
>>> Hello , i have the following code in matlab and trying to do it in
>>> matplotlib.
>>>
>>> I have this code in matlab (in a function showGraphs):
>>> ...
>>> m = size(myList, 3);
>>> for k = 1:m
>>> g = myList(:, :, k);
>>> image(g + 1)
>>> axis off
>>> axis square
>>> M(k) = getframe;
>>> end;
>>>
>>> and in another file (another function):
>>> ...
>>> M = showGraphs(grids)
>>> movie(M, 1)
>>>
>>>
>>>
>>> I did so far:
>>>
>>> def showGraphs(data):
>>> data=sc.array([data])
>>> n=sc.shape(data)[2]
>>> for k in range(n):
>>> mydata=data[:,:,k]
>>> #plt.imshow(mydata+1)-->> this doesn't work
>>>
>>> Also ,in order to do the animation :
>>>
>>> grids=...(result from another function)
>>> result=showGraph(grids)
>>> fig=plt.figure()
>>> ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
>>> plt.show()
>>>
>>> Right now the program says "TypeError: 'NoneType' object is not
>>> callable" (it has errors in the animation call)
>>>
>>> What should be my approach to this in order to have the animation?
>>>
>>> Thank you!
>>>
>>>
>> You're getting that error because the second argument to FuncAnimation
>> (`result` in your example) should be a function (not always; see example 2
>> linked below). Right now, if your `showGraphs` function is defined in full,
>> it returns a value of None, which gets saved to `result` (hence the error).
>>
>> You should take a look at some of the image animation examples 
>> (ex1,
>> ex2
>> ).
>>
>> -Tony
>>
>>
>>  I did now :
>>
>>
>> def showGraphs(data):
>> data=sc.array([data])
>> n=sc.shape(data)[2]
>>  ims=[]
>>
>> for k in range(n):
>> mydata=data[:,:,k]
>>  im=plt.imshow(mydata+1)
>> ims.append([im])
>> return ims
>>
>> and now it gives me "TypeError: Invalid dimensions for image data.
>>
>>
> Please post short, but executable examples when possible. I'm not sure
> what your data looks like, but your call to `sc.array` is strange (I'm not
> sure why you have square brackets, which effectively adds an unnecessary
> dimension to your data).
>
> The code attached below should work.
>
> Cheers,
> -Tony
>
> import numpy as np
> import matplotlib.pyplot as plt
> from matplotlib.animation import ArtistAnimation
>
>
> fig = plt.figure()
>
> def showGraphs(data):
> data = np.asarray(data) # unnecessary in this example
> n = np.shape(data)[2]
>
> ims = []
> #for mydata in np.rollaxis(data, -1):
> for k in range(n):
> mydata = data[:, :, k]
> im = plt.imshow(mydata)
> ims.append([im])
> return ims
>
> # 5 frames of a random 20 x 20 image
> data = np.random.uniform(size=(20, 20, 5))
> ims = showGraphs(data)
>
> ani = ArtistAnimation(fig, ims)
> plt.show()
>
> Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't convert right
> the matlab code below?)
> The data in the showGraphs function is the result from this function (in
> matlab):
> .
> grids = zeros(n, n, t + 1);
> grids(:, :, 1) = rest;
> for i = 2:(t + 1)
> Extended = extendLat1(rest);
> rest = applyExtended(Extended);
> grids(:, :, i) = rest;
> end;
>
> And i did this in python:
>
>grids=sc.zeros((area,area,t+1))
> rest=grids[:,:,0]
> for i in range(1,t):
> extended=extend(rest)
> rest=apply_extend(extended)
> grids[:,:,i]=rest
> return grids
>
> Thanks for helping!
>
>  Any help?Thanks!
>
> Sorry, but could you be a bit clearer:
* Did the example I provide work for you?
* Assuming it did, are you essentially replacing `data` in my example with
`grids` in this most recent example?
* I don't get 2 figures: are you asking about the code from my last message?
* Please provide a minimal, *executable* example

-Tony
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plotting contour in X-Z plane

2012-01-23 Thread Moore, Eric (NIH/NIDDK) [F]


From: [email protected] [mailto:[email protected]] On Behalf Of Benjamin 
Root
Sent: Monday, January 23, 2012 10:49 AM
To: Moore, Eric (NIH/NIDDK) [F]
Cc: [email protected]
Subject: Re: [Matplotlib-users] Plotting contour in X-Z plane


On Thu, Jan 19, 2012 at 12:01 PM, Moore, Eric (NIH/NIDDK) [F] 
mailto:[email protected]>> wrote:
> -Original Message-
> From: alw46 
> [mailto:[email protected]]
> Sent: Thursday, January 19, 2012 11:31 AM
> To: 
> [email protected]
> Subject: [Matplotlib-users] Plotting contour in X-Z plane
>
>
> Hi All,
>
> I have a question similar to one posted on Aug 30, 2011 titled
> "Plotting 2D
> contourf in Axes3D X-Z plane instead of X-Y plane".  In fact, it is the
> same
> question, and I can't seem to find a satisfactory answer anywhere.
>
> I've attached an image of what I've done in the X-Y plane for
> reference.
> Like the other post, I'd like to do something similar to what I've done
> in
> the X-Y direction, but in the X-Z and Y-Z planes.  Since I've set up a
> grid
> of points throughout the space, this effectively allows me to take
> "section
> cuts" in different directions in the space.  But I can't seem to figure
> out
> how to do it.  I've switched around the "z-dir", as well as replacing X
> and
> Y with Z in ax.contourf.  For reference, I'm using matplotlib 1.1.0.
>
> I'm trying to achieve a similar affect to Mayavi's 'image_plane_widget'
> to
> take volume slices, but using matplotlib.
>
> http://old.nabble.com/file/p33168965/contours_xy.png
> --
> View this message in context: http://old.nabble.com/Plotting-contour-
> in-X-Z-plane-tp33168965p33168965.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
I've attached a function that I think does something similar to what you want, 
although without quite all of the bells and whistles you're looking for.  I'm 
sure there are better ways than just plotting so many lines, but it worked for 
quickly looking at some data for me.

Eric

Eric,

That is a neat example.  Do you mind if I clean it up and include it in the mpl 
gallary?

Ben Root

Ben,
 I don't mind.  Please feel free to do so.
Eric

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Gousios George

Στις 23/01/2012 06:52 μμ, ο/η Tony Yu έγραψε:



2012/1/23 Gousios George >


Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:

Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 11:31 AM, Gousios George
mailto:[email protected]>> wrote:

Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 9:07 AM, Gousios George
mailto:[email protected]>> wrote:

Hello , i have the following code in matlab and trying
to do it in
matplotlib.

I have this code in matlab (in a function showGraphs):
...
m = size(myList, 3);
for k = 1:m
g = myList(:, :, k);
image(g + 1)
axis off
axis square
M(k) = getframe;
end;

and in another file (another function):
...
M = showGraphs(grids)
movie(M, 1)



I did so far:

def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
for k in range(n):
mydata=data[:,:,k]
#plt.imshow(mydata+1)-->> this doesn't work

Also ,in order to do the animation :

grids=...(result from another function)
result=showGraph(grids)
fig=plt.figure()
ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
plt.show()

Right now the program says "TypeError: 'NoneType'
object is not
callable" (it has errors in the animation call)

What should be my approach to this in order to have the
animation?

Thank you!


You're getting that error because the second argument to
FuncAnimation (`result` in your example) should be a
function (not always; see example 2 linked below). Right
now, if your `showGraphs` function is defined in full, it
returns a value of None, which gets saved to `result`
(hence the error).

You should take a look at some of the image animation
examples (ex1

,
ex2

).

-Tony



I did now :


def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
ims=[]

for k in range(n):
mydata=data[:,:,k]
im=plt.imshow(mydata+1)
ims.append([im])
return ims

and now it gives me "TypeError: Invalid dimensions for image
data.


Please post short, but executable examples when possible. I'm
not sure what your data looks like, but your call to `sc.array`
is strange (I'm not sure why you have square brackets, which
effectively adds an unnecessary dimension to your data).

The code attached below should work.

Cheers,
-Tony

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import ArtistAnimation


fig = plt.figure()

def showGraphs(data):
data = np.asarray(data) # unnecessary in this example
n = np.shape(data)[2]

ims = []
#for mydata in np.rollaxis(data, -1):
for k in range(n):
mydata = data[:, :, k]
im = plt.imshow(mydata)
ims.append([im])
return ims

# 5 frames of a random 20 x 20 image
data = np.random.uniform(size=(20, 20, 5))
ims = showGraphs(data)

ani = ArtistAnimation(fig, ims)
plt.show()

Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't
convert right the matlab code below?)
The data in the showGraphs function is the result from this
function (in matlab):
.
grids = zeros(n, n, t + 1);
grids(:, :, 1) = rest;
for i = 2:(t + 1)
Extended = extendLat1(rest);
rest = applyExtended(Extended);
grids(:, :, i) = rest;
end;

And i did this in python:

   grids=sc.zeros((area,area,t+1))
rest=grids[:,:,0]
for i in range(1,t):
extended=extend(rest)
rest=apply_extend(extended)
grids[:,:,i]=rest
return grids

Thanks for helping!


Any help?Thanks!

Sorry, but could you be a bit clearer:
* Did the example I provide work for you?
* Assuming it did, are you essentially replacing `data` in my example 
with `grids` in this most recent example?
* I don't get 2 figures: are you asking about the code from my last 
message?

* Please provide a minimal, *executable* example

-Tony

Ok,i 'll try!

1) Yes,your example works fine.
2) Yes,i return grids from another function (work) doing :

grids=work(area,...,time)
r

Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Tony Yu
2012/1/23 Gousios George 

> **
> Στις 23/01/2012 06:52 μμ, ο/η Tony Yu έγραψε:
>
>
>
> 2012/1/23 Gousios George 
>
>>  Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:
>>
>> Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:
>>
>>
>>
>> On Sat, Jan 21, 2012 at 11:31 AM, Gousios George 
>> wrote:
>>
>>>  Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:
>>>
>>>
>>>
>>> On Sat, Jan 21, 2012 at 9:07 AM, Gousios George 
>>> wrote:
>>>
 Hello , i have the following code in matlab and trying to do it in
 matplotlib.

 I have this code in matlab (in a function showGraphs):
 ...
 m = size(myList, 3);
 for k = 1:m
 g = myList(:, :, k);
 image(g + 1)
 axis off
 axis square
 M(k) = getframe;
 end;

 and in another file (another function):
 ...
 M = showGraphs(grids)
 movie(M, 1)



 I did so far:

 def showGraphs(data):
 data=sc.array([data])
 n=sc.shape(data)[2]
 for k in range(n):
 mydata=data[:,:,k]
 #plt.imshow(mydata+1)-->> this doesn't work

 Also ,in order to do the animation :

 grids=...(result from another function)
 result=showGraph(grids)
 fig=plt.figure()
 ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
 plt.show()

 Right now the program says "TypeError: 'NoneType' object is not
 callable" (it has errors in the animation call)

 What should be my approach to this in order to have the animation?

 Thank you!


>>> You're getting that error because the second argument to FuncAnimation
>>> (`result` in your example) should be a function (not always; see example 2
>>> linked below). Right now, if your `showGraphs` function is defined in full,
>>> it returns a value of None, which gets saved to `result` (hence the error).
>>>
>>> You should take a look at some of the image animation examples 
>>> (ex1,
>>> ex2
>>> ).
>>>
>>> -Tony
>>>
>>>
>>>  I did now :
>>>
>>>
>>> def showGraphs(data):
>>> data=sc.array([data])
>>> n=sc.shape(data)[2]
>>>  ims=[]
>>>
>>> for k in range(n):
>>> mydata=data[:,:,k]
>>>  im=plt.imshow(mydata+1)
>>> ims.append([im])
>>> return ims
>>>
>>> and now it gives me "TypeError: Invalid dimensions for image data.
>>>
>>>
>> Please post short, but executable examples when possible. I'm not sure
>> what your data looks like, but your call to `sc.array` is strange (I'm not
>> sure why you have square brackets, which effectively adds an unnecessary
>> dimension to your data).
>>
>> The code attached below should work.
>>
>> Cheers,
>> -Tony
>>
>> import numpy as np
>> import matplotlib.pyplot as plt
>> from matplotlib.animation import ArtistAnimation
>>
>>
>> fig = plt.figure()
>>
>> def showGraphs(data):
>> data = np.asarray(data) # unnecessary in this example
>> n = np.shape(data)[2]
>>
>> ims = []
>> #for mydata in np.rollaxis(data, -1):
>> for k in range(n):
>> mydata = data[:, :, k]
>> im = plt.imshow(mydata)
>> ims.append([im])
>> return ims
>>
>> # 5 frames of a random 20 x 20 image
>> data = np.random.uniform(size=(20, 20, 5))
>> ims = showGraphs(data)
>>
>> ani = ArtistAnimation(fig, ims)
>> plt.show()
>>
>> Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't convert
>> right the matlab code below?)
>> The data in the showGraphs function is the result from this function (in
>> matlab):
>> .
>> grids = zeros(n, n, t + 1);
>> grids(:, :, 1) = rest;
>> for i = 2:(t + 1)
>> Extended = extendLat1(rest);
>> rest = applyExtended(Extended);
>> grids(:, :, i) = rest;
>> end;
>>
>> And i did this in python:
>>
>>grids=sc.zeros((area,area,t+1))
>> rest=grids[:,:,0]
>> for i in range(1,t):
>> extended=extend(rest)
>> rest=apply_extend(extended)
>> grids[:,:,i]=rest
>> return grids
>>
>> Thanks for helping!
>>
>>  Any help?Thanks!
>>
>>  Sorry, but could you be a bit clearer:
> * Did the example I provide work for you?
> * Assuming it did, are you essentially replacing `data` in my example with
> `grids` in this most recent example?
> * I don't get 2 figures: are you asking about the code from my last
> message?
> * Please provide a minimal, *executable* example
>
> -Tony
>
> Ok,i 'll try!
>
> 1) Yes,your example works fine.
> 2) Yes,i return grids from another function (work) doing :
>
> grids=work(area,...,time)
> result=showGraphs(grids)
> ani=ArtistAnimation(fig,result)
> plt.show()
>
> The contents of the work function are shown above.
> I just want to make sure that i have done the conversion from matlab right.
> Maybe the problem is somewhere else?
>
> Thank you.
>
>
Did you get 2 figures with my original example, or just in yo

Re: [Matplotlib-users] MQMQ: How to adjust the size and scale of the x-y axis of the graph.Thanks.

2012-01-23 Thread MQMQ

Thank you so much, I will follow your advice.:)

MQ

MQMQ wrote:
> 
> Dear all, 
> 
> Could you guys share your experience on:
> How to adjust the size and scale of the x-y axis of the plot (e.g. how to
> resize the "0 1 2" on x axis ), Thanks?
> And special commands in matplotlib?
> 
> Thank you so much in advanced.
> MQMQ
> 

-- 
View this message in context: 
http://old.nabble.com/MQMQ%3A-How-to-adjust-the-size-and-scale-of-the-x-y-axis-of-the-graph.Thanks.-tp33177496p33189796.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Gousios George

Στις 23/01/2012 07:48 μμ, ο/η Tony Yu έγραψε:



2012/1/23 Gousios George >


Στις 23/01/2012 06:52 μμ, ο/η Tony Yu έγραψε:



2012/1/23 Gousios George mailto:[email protected]>>

Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:

Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 11:31 AM, Gousios George
mailto:[email protected]>> wrote:

Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 9:07 AM, Gousios George
mailto:[email protected]>>
wrote:

Hello , i have the following code in matlab and
trying to do it in
matplotlib.

I have this code in matlab (in a function showGraphs):
...
m = size(myList, 3);
for k = 1:m
g = myList(:, :, k);
image(g + 1)
axis off
axis square
M(k) = getframe;
end;

and in another file (another function):
...
M = showGraphs(grids)
movie(M, 1)



I did so far:

def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
for k in range(n):
mydata=data[:,:,k]
#plt.imshow(mydata+1)-->> this doesn't
work

Also ,in order to do the animation :

grids=...(result from another function)
result=showGraph(grids)
fig=plt.figure()
ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
plt.show()

Right now the program says "TypeError: 'NoneType'
object is not
callable" (it has errors in the animation call)

What should be my approach to this in order to
have the animation?

Thank you!


You're getting that error because the second argument
to FuncAnimation (`result` in your example) should be
a function (not always; see example 2 linked below).
Right now, if your `showGraphs` function is defined in
full, it returns a value of None, which gets saved to
`result` (hence the error).

You should take a look at some of the image animation
examples (ex1

,
ex2

).

-Tony



I did now :


def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
ims=[]

for k in range(n):
mydata=data[:,:,k]
im=plt.imshow(mydata+1)
ims.append([im])
return ims

and now it gives me "TypeError: Invalid dimensions for
image data.


Please post short, but executable examples when possible.
I'm not sure what your data looks like, but your call to
`sc.array` is strange (I'm not sure why you have square
brackets, which effectively adds an unnecessary dimension
to your data).

The code attached below should work.

Cheers,
-Tony

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import ArtistAnimation


fig = plt.figure()

def showGraphs(data):
data = np.asarray(data) # unnecessary in this example
n = np.shape(data)[2]

ims = []
#for mydata in np.rollaxis(data, -1):
for k in range(n):
mydata = data[:, :, k]
im = plt.imshow(mydata)
ims.append([im])
return ims

# 5 frames of a random 20 x 20 image
data = np.random.uniform(size=(20, 20, 5))
ims = showGraphs(data)

ani = ArtistAnimation(fig, ims)
plt.show()

Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't
convert right the matlab code below?)
The data in the showGraphs function is the result from this
function (in matlab):
.
grids = zeros(n, n, t + 1);
grids(:, :, 1) = rest;
for i = 2:(t + 1)
Extended = extendLat1(rest);
rest = applyExtended(Extended);
grids(:, :, i) = rest;
end;

And i did this in python:

   grids=sc.zeros((area,area,t+1))
rest=grids[:,:,0]
for i in range(1,t):
extended=extend(rest)
rest=a

Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Benjamin Root
2012/1/23 Gousios George 

> **
> Στις 23/01/2012 07:48 μμ, ο/η Tony Yu έγραψε:
>
>
>
> 2012/1/23 Gousios George 
>
>>  Στις 23/01/2012 06:52 μμ, ο/η Tony Yu έγραψε:
>>
>>
>>
>> 2012/1/23 Gousios George 
>>
>>>  Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:
>>>
>>> Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:
>>>
>>>
>>>
>>> On Sat, Jan 21, 2012 at 11:31 AM, Gousios George 
>>> wrote:
>>>
  Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:



 On Sat, Jan 21, 2012 at 9:07 AM, Gousios George 
 wrote:

> Hello , i have the following code in matlab and trying to do it in
> matplotlib.
>
> I have this code in matlab (in a function showGraphs):
> ...
> m = size(myList, 3);
> for k = 1:m
> g = myList(:, :, k);
> image(g + 1)
> axis off
> axis square
> M(k) = getframe;
> end;
>
> and in another file (another function):
> ...
> M = showGraphs(grids)
> movie(M, 1)
>
>
>
> I did so far:
>
> def showGraphs(data):
> data=sc.array([data])
> n=sc.shape(data)[2]
> for k in range(n):
> mydata=data[:,:,k]
> #plt.imshow(mydata+1)-->> this doesn't work
>
> Also ,in order to do the animation :
>
> grids=...(result from another function)
> result=showGraph(grids)
> fig=plt.figure()
> ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
> plt.show()
>
> Right now the program says "TypeError: 'NoneType' object is not
> callable" (it has errors in the animation call)
>
> What should be my approach to this in order to have the animation?
>
> Thank you!
>
>
 You're getting that error because the second argument to FuncAnimation
 (`result` in your example) should be a function (not always; see example 2
 linked below). Right now, if your `showGraphs` function is defined in full,
 it returns a value of None, which gets saved to `result` (hence the error).

 You should take a look at some of the image animation examples 
 (ex1,
 ex2
 ).

 -Tony


  I did now :


 def showGraphs(data):
 data=sc.array([data])
 n=sc.shape(data)[2]
  ims=[]

 for k in range(n):
 mydata=data[:,:,k]
  im=plt.imshow(mydata+1)
 ims.append([im])
 return ims

 and now it gives me "TypeError: Invalid dimensions for image data.


>>> Please post short, but executable examples when possible. I'm not sure
>>> what your data looks like, but your call to `sc.array` is strange (I'm not
>>> sure why you have square brackets, which effectively adds an unnecessary
>>> dimension to your data).
>>>
>>> The code attached below should work.
>>>
>>> Cheers,
>>> -Tony
>>>
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from matplotlib.animation import ArtistAnimation
>>>
>>>
>>> fig = plt.figure()
>>>
>>> def showGraphs(data):
>>> data = np.asarray(data) # unnecessary in this example
>>> n = np.shape(data)[2]
>>>
>>> ims = []
>>> #for mydata in np.rollaxis(data, -1):
>>> for k in range(n):
>>> mydata = data[:, :, k]
>>> im = plt.imshow(mydata)
>>> ims.append([im])
>>> return ims
>>>
>>> # 5 frames of a random 20 x 20 image
>>> data = np.random.uniform(size=(20, 20, 5))
>>> ims = showGraphs(data)
>>>
>>> ani = ArtistAnimation(fig, ims)
>>> plt.show()
>>>
>>> Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't convert
>>> right the matlab code below?)
>>> The data in the showGraphs function is the result from this function (in
>>> matlab):
>>> .
>>> grids = zeros(n, n, t + 1);
>>> grids(:, :, 1) = rest;
>>> for i = 2:(t + 1)
>>> Extended = extendLat1(rest);
>>> rest = applyExtended(Extended);
>>> grids(:, :, i) = rest;
>>> end;
>>>
>>> And i did this in python:
>>>
>>>grids=sc.zeros((area,area,t+1))
>>> rest=grids[:,:,0]
>>> for i in range(1,t):
>>> extended=extend(rest)
>>> rest=apply_extend(extended)
>>> grids[:,:,i]=rest
>>> return grids
>>>
>>> Thanks for helping!
>>>
>>>  Any help?Thanks!
>>>
>>>  Sorry, but could you be a bit clearer:
>> * Did the example I provide work for you?
>> * Assuming it did, are you essentially replacing `data` in my example
>> with `grids` in this most recent example?
>> * I don't get 2 figures: are you asking about the code from my last
>> message?
>> * Please provide a minimal, *executable* example
>>
>> -Tony
>>
>>  Ok,i 'll try!
>>
>> 1) Yes,your example works fine.
>> 2) Yes,i return grids from another function (work) doing :
>>
>> grids=work(area,...,time)
>> result=showGraphs(grids)
>> ani=ArtistAnimation(fig,result)
>>  

Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Gousios George

Στις 23/01/2012 08:10 μμ, ο/η Benjamin Root έγραψε:
2012/1/23 Gousios George >


Στις 23/01/2012 07:48 μμ, ο/η Tony Yu έγραψε:



2012/1/23 Gousios George mailto:[email protected]>>

Στις 23/01/2012 06:52 μμ, ο/η Tony Yu έγραψε:



2012/1/23 Gousios George mailto:[email protected]>>

Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:

Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 11:31 AM, Gousios George
mailto:[email protected]>>
wrote:

Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:



On Sat, Jan 21, 2012 at 9:07 AM, Gousios George
mailto:[email protected]>> wrote:

Hello , i have the following code in matlab
and trying to do it in
matplotlib.

I have this code in matlab (in a function
showGraphs):
...
m = size(myList, 3);
for k = 1:m
g = myList(:, :, k);
image(g + 1)
axis off
axis square
M(k) = getframe;
end;

and in another file (another function):
...
M = showGraphs(grids)
movie(M, 1)



I did so far:

def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
for k in range(n):
mydata=data[:,:,k]
#plt.imshow(mydata+1)-->> this
doesn't work

Also ,in order to do the animation :

grids=...(result from another function)
result=showGraph(grids)
fig=plt.figure()

ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
plt.show()

Right now the program says "TypeError:
'NoneType' object is not
callable" (it has errors in the animation call)

What should be my approach to this in order
to have the animation?

Thank you!


You're getting that error because the second
argument to FuncAnimation (`result` in your
example) should be a function (not always; see
example 2 linked below). Right now, if your
`showGraphs` function is defined in full, it
returns a value of None, which gets saved to
`result` (hence the error).

You should take a look at some of the image
animation examples (ex1

,
ex2

).

-Tony



I did now :


def showGraphs(data):
data=sc.array([data])
n=sc.shape(data)[2]
ims=[]

for k in range(n):
mydata=data[:,:,k]
im=plt.imshow(mydata+1)
ims.append([im])
return ims

and now it gives me "TypeError: Invalid dimensions
for image data.


Please post short, but executable examples when
possible. I'm not sure what your data looks like, but
your call to `sc.array` is strange (I'm not sure why
you have square brackets, which effectively adds an
unnecessary dimension to your data).

The code attached below should work.

Cheers,
-Tony

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import ArtistAnimation


fig = plt.figure()

def showGraphs(data):
data = np.asarray(data) # unnecessary in this example
n = np.shape(data)[2]

ims = []
#for mydata in np.rollaxis(data, -1):
for k in range(n):
mydata = data[:, :, k]
im = plt.imshow(mydata)
ims.append([im])
return ims

# 5 frames of a random 20 x 20 image
data = np.random.uniform(size=(20, 20, 5))
ims = showGraphs(data)

ani = ArtistAnimation(fig, ims)
plt.show()

Now,it gives me 2 figures (why 2?) but empty.(maybe i
didn't convert right the matlab code be

Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Stan West
> From: Russ Dill [mailto:[email protected]] 
> Sent: Saturday, January 21, 2012 16:31
> 
> I'm using matplotlib from pylab to generate eye patterns for signal
> simulations.

...

> Is there any way within matplotlib to do that right now?

One way combines Numpy's histogram2d and matplotlib's imshow, as in the
example in the histogram2d docs [1].  The example's x array should become all
of the time samples in your traces, strung together in one dimension; the y
array, the corresponding voltage samples.

If you have certain structure, such as a regular and consistent grid of times,
you might instead construct a series of vertical, 1-d histograms (paying
attention to normalization); column-stack them into the final 2-d histogram;
and again plot with imshow.

[1]
http://docs.scipy.org/doc/numpy-1.6.0/reference/generated/numpy.histogram2d.ht
ml


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to create a movie?? (from matlab code)

2012-01-23 Thread Tony Yu
2012/1/23 Gousios George 

> **
> Στις 23/01/2012 08:10 μμ, ο/η Benjamin Root έγραψε:
>
> 2012/1/23 Gousios George 
>
>>  Στις 23/01/2012 07:48 μμ, ο/η Tony Yu έγραψε:
>>
>>
>>
>> 2012/1/23 Gousios George 
>>
>>>  Στις 23/01/2012 06:52 μμ, ο/η Tony Yu έγραψε:
>>>
>>>
>>>
>>> 2012/1/23 Gousios George 
>>>
  Στις 21/01/2012 07:43 μμ, ο/η Gousios George έγραψε:

 Στις 21/01/2012 07:05 μμ, ο/η Tony Yu έγραψε:



 On Sat, Jan 21, 2012 at 11:31 AM, Gousios George >>> > wrote:

>  Στις 21/01/2012 04:54 μμ, ο/η Tony Yu έγραψε:
>
>
>
> On Sat, Jan 21, 2012 at 9:07 AM, Gousios George  > wrote:
>
>> Hello , i have the following code in matlab and trying to do it in
>> matplotlib.
>>
>> I have this code in matlab (in a function showGraphs):
>> ...
>> m = size(myList, 3);
>> for k = 1:m
>> g = myList(:, :, k);
>> image(g + 1)
>> axis off
>> axis square
>> M(k) = getframe;
>> end;
>>
>> and in another file (another function):
>> ...
>> M = showGraphs(grids)
>> movie(M, 1)
>>
>>
>>
>> I did so far:
>>
>> def showGraphs(data):
>> data=sc.array([data])
>> n=sc.shape(data)[2]
>> for k in range(n):
>> mydata=data[:,:,k]
>> #plt.imshow(mydata+1)-->> this doesn't work
>>
>> Also ,in order to do the animation :
>>
>> grids=...(result from another function)
>> result=showGraph(grids)
>> fig=plt.figure()
>> ani=animation.FuncAnimation(fig,result,interval=30,blit=True)
>> plt.show()
>>
>> Right now the program says "TypeError: 'NoneType' object is not
>> callable" (it has errors in the animation call)
>>
>> What should be my approach to this in order to have the animation?
>>
>> Thank you!
>>
>>
> You're getting that error because the second argument to FuncAnimation
> (`result` in your example) should be a function (not always; see example 2
> linked below). Right now, if your `showGraphs` function is defined in 
> full,
> it returns a value of None, which gets saved to `result` (hence the 
> error).
>
> You should take a look at some of the image animation examples 
> (ex1,
> ex2
> ).
>
> -Tony
>
>
>  I did now :
>
>
> def showGraphs(data):
> data=sc.array([data])
> n=sc.shape(data)[2]
>  ims=[]
>
> for k in range(n):
> mydata=data[:,:,k]
>  im=plt.imshow(mydata+1)
> ims.append([im])
> return ims
>
> and now it gives me "TypeError: Invalid dimensions for image data.
>
>
 Please post short, but executable examples when possible. I'm not sure
 what your data looks like, but your call to `sc.array` is strange (I'm not
 sure why you have square brackets, which effectively adds an unnecessary
 dimension to your data).

 The code attached below should work.

 Cheers,
 -Tony

 import numpy as np
 import matplotlib.pyplot as plt
 from matplotlib.animation import ArtistAnimation


 fig = plt.figure()

 def showGraphs(data):
 data = np.asarray(data) # unnecessary in this example
 n = np.shape(data)[2]

 ims = []
 #for mydata in np.rollaxis(data, -1):
 for k in range(n):
 mydata = data[:, :, k]
 im = plt.imshow(mydata)
 ims.append([im])
 return ims

 # 5 frames of a random 20 x 20 image
 data = np.random.uniform(size=(20, 20, 5))
 ims = showGraphs(data)

 ani = ArtistAnimation(fig, ims)
 plt.show()

 Now,it gives me 2 figures (why 2?) but empty.(maybe i didn't convert
 right the matlab code below?)
 The data in the showGraphs function is the result from this function
 (in matlab):
 .
 grids = zeros(n, n, t + 1);
 grids(:, :, 1) = rest;
 for i = 2:(t + 1)
 Extended = extendLat1(rest);
 rest = applyExtended(Extended);
 grids(:, :, i) = rest;
 end;

 And i did this in python:

grids=sc.zeros((area,area,t+1))
 rest=grids[:,:,0]
 for i in range(1,t):
 extended=extend(rest)
 rest=apply_extend(extended)
 grids[:,:,i]=rest
 return grids

 Thanks for helping!

  Any help?Thanks!

  Sorry, but could you be a bit clearer:
>>> * Did the example I provide work for you?
>>> * Assuming it did, are you essentially replacing `data` in my example
>>> with `grids` in this most recent example?
>>> * I don't get 2 figures: are you asking about the code from my last
>>> message?
>>> * Please provide a

Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Russ Dill
On Mon, Jan 23, 2012 at 11:17 AM, Stan West  wrote:
>> From: Russ Dill [mailto:[email protected]]
>> Sent: Saturday, January 21, 2012 16:31
>>
>> I'm using matplotlib from pylab to generate eye patterns for signal
>> simulations.
>
> ...
>
>> Is there any way within matplotlib to do that right now?
>
> One way combines Numpy's histogram2d and matplotlib's imshow, as in the
> example in the histogram2d docs [1].  The example's x array should become all
> of the time samples in your traces, strung together in one dimension; the y
> array, the corresponding voltage samples.
>

I'll try it out and see what I get, but I don't think it will work so
well. The problem is that while the data is made up of x/y samples, it
actually represents a line. The samples should be evenly distributed
not along the x or y axis, but along the length of the line. I feel
like I'll need a line drawing algorithm.

(For example, if samples are evenly distributed along the x axis, a 89
degree line is highly under-represented, but a 1 degree line is highly
over-represented. The number of samples should be sqrt(dx^2 + dy^2),
but with evenly spaced x samples, its just dx.

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] beginner examples using matplotlib.transforms?

2012-01-23 Thread reckoner
Hi,

I am trying to create a sequence of rotated rectangles of various 
sizes/orientations.  I have been looking at the following page:

http://matplotlib.sourceforge.net/devel/transformations.html

But I can't find any examples of how to use these transformations and 
then show the resulting figures. I am trying to create a sequence of 
frames for a rectangle tumbling forward. This means I would need to 
daisychain the transformations noted above.

Any help getting started would be greatly appreciated!

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Ethan Swint


On 1/23/2012 1:55 PM, Russ Dill wrote:
> On Mon, Jan 23, 2012 at 11:17 AM, Stan West  wrote:
>>> From: Russ Dill [mailto:[email protected]]
>>> Sent: Saturday, January 21, 2012 16:31
>>>
>>> I'm using matplotlib from pylab to generate eye patterns for signal
>>> simulations.
>> ...
>>
>>> Is there any way within matplotlib to do that right now?
>> One way combines Numpy's histogram2d and matplotlib's imshow, as in the
>> example in the histogram2d docs [1].  The example's x array should become all
>> of the time samples in your traces, strung together in one dimension; the y
>> array, the corresponding voltage samples.
>>
> I'll try it out and see what I get, but I don't think it will work so
> well. The problem is that while the data is made up of x/y samples, it
> actually represents a line. The samples should be evenly distributed
> not along the x or y axis, but along the length of the line. I feel
> like I'll need a line drawing algorithm.
>
> (For example, if samples are evenly distributed along the x axis, a 89
> degree line is highly under-represented, but a 1 degree line is highly
> over-represented. The number of samples should be sqrt(dx^2 + dy^2),
> but with evenly spaced x samples, its just dx.

I don't know of a way to directly produce the LeCroy heatmap in Python, 
so here's my idea for a hack:
*Each sample point you have from the trace represents a point in XY 
coordinates.
*Similarly, the plot area is filled with regularly spaced XY coordinates.
*Every trace sample will fall within a square bounding box with four points.
*Each plot area point gets a membership value, based on distance between 
centers of the sample point and the plot area point.
*To construct the heat diagram, sum the membership values of all sample 
points for all traces.
*Display it with a contour plot, but without the isovalue lines.

-Ethan

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] beginner examples using matplotlib.transforms?

2012-01-23 Thread Tony Yu
On Mon, Jan 23, 2012 at 2:43 PM, reckoner  wrote:

> Hi,
>
> I am trying to create a sequence of rotated rectangles of various
> sizes/orientations.  I have been looking at the following page:
>
> http://matplotlib.sourceforge.net/devel/transformations.html
>
> But I can't find any examples of how to use these transformations and
> then show the resulting figures. I am trying to create a sequence of
> frames for a rectangle tumbling forward. This means I would need to
> daisychain the transformations noted above.
>
> Any help getting started would be greatly appreciated!
>
>
Have you seen the Transformations
Tutorial?
It has a number of usage examples.

Cheers,
-Tony
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Benjamin Root
On Mon, Jan 23, 2012 at 1:46 PM, Ethan Swint  wrote:

>
>
> On 1/23/2012 1:55 PM, Russ Dill wrote:
> > On Mon, Jan 23, 2012 at 11:17 AM, Stan West
>  wrote:
> >>> From: Russ Dill [mailto:[email protected]]
> >>> Sent: Saturday, January 21, 2012 16:31
> >>>
> >>> I'm using matplotlib from pylab to generate eye patterns for signal
> >>> simulations.
> >> ...
> >>
> >>> Is there any way within matplotlib to do that right now?
> >> One way combines Numpy's histogram2d and matplotlib's imshow, as in the
> >> example in the histogram2d docs [1].  The example's x array should
> become all
> >> of the time samples in your traces, strung together in one dimension;
> the y
> >> array, the corresponding voltage samples.
> >>
> > I'll try it out and see what I get, but I don't think it will work so
> > well. The problem is that while the data is made up of x/y samples, it
> > actually represents a line. The samples should be evenly distributed
> > not along the x or y axis, but along the length of the line. I feel
> > like I'll need a line drawing algorithm.
> >
> > (For example, if samples are evenly distributed along the x axis, a 89
> > degree line is highly under-represented, but a 1 degree line is highly
> > over-represented. The number of samples should be sqrt(dx^2 + dy^2),
> > but with evenly spaced x samples, its just dx.
>
> I don't know of a way to directly produce the LeCroy heatmap in Python,
> so here's my idea for a hack:
> *Each sample point you have from the trace represents a point in XY
> coordinates.
> *Similarly, the plot area is filled with regularly spaced XY coordinates.
> *Every trace sample will fall within a square bounding box with four
> points.
> *Each plot area point gets a membership value, based on distance between
> centers of the sample point and the plot area point.
> *To construct the heat diagram, sum the membership values of all sample
> points for all traces.
> *Display it with a contour plot, but without the isovalue lines.
>
> -Ethan
>
>
matplotlib also has hexbin() if that helps.

http://matplotlib.sourceforge.net/api/axes_api.html?highlight=hexbin#matplotlib.axes.Axes.hexbin

Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] beginner examples using matplotlib.transforms?

2012-01-23 Thread Benjamin Root
On Mon, Jan 23, 2012 at 2:21 PM, Tony Yu  wrote:

>
>
> On Mon, Jan 23, 2012 at 2:43 PM, reckoner  wrote:
>
>> Hi,
>>
>> I am trying to create a sequence of rotated rectangles of various
>> sizes/orientations.  I have been looking at the following page:
>>
>> http://matplotlib.sourceforge.net/devel/transformations.html
>>
>> But I can't find any examples of how to use these transformations and
>> then show the resulting figures. I am trying to create a sequence of
>> frames for a rectangle tumbling forward. This means I would need to
>> daisychain the transformations noted above.
>>
>> Any help getting started would be greatly appreciated!
>>
>>
> Have you seen the Transformations 
> Tutorial?
> It has a number of usage examples.
>
> Cheers,
> -Tony
>
>
Do note that while I think what you want to do is techinically feasible,
the Transformation framework is probably not really intended for this
purpose and may feel awkward. That being said, I think that this example
may be the closest to what you want to do:

http://matplotlib.sourceforge.net/users/transforms_tutorial.html#using-offset-transforms-to-create-a-shadow-effect

Cheers!
Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Paul Ivanov
Hi Russ,

Russ Dill, on 2012-01-21 13:30,  wrote:
> I'm using matplotlib from pylab to generate eye patterns for signal
> simulations. My output pretty much looks like this:
> 
> http://www.flickr.com/photos/31208937@N06/6079131690/
> 
> Its pretty useful as it allows one to quickly see the size of the eye
> opening, the maximum/minimum voltage, etc. I'd really like to be able
> to create a heat diagram, like these:
> 
> http://www.lecroy.com/images/oscilloscope/series/waveexpert/opening-spread2_lg.jpg
> http://www.lecroy.com/images/oscilloscope/series/waveexpert/opening-spread1_lg.jpg
> http://www.iec.org/newsletter/august07_2/imgs/bb2_fig_1.gif
> http://www.altera.com/devices/fpga/stratix-fpgas/stratix-ii/stratix-ii-gx/images/s2gx-rollout-6g-eye.jpg
> 
> Is there any way within matplotlib to do that right now?

the quick and dirty way to get close to what you want is to add
an alpha value to the lines you're already plotting. Here's a
small example:

  x = np.arange(0,3,.01)
  y = np.sin(x**2)
  all_x,all_y = [],[]
  ax = plt.gca()
  for i in range(100):
  noisex = np.random.randn(1)*.04
  noisey = (np.random.randn(x.shape[0])*.2)**3
  ax.plot(x+noisex,y+noisey, color='b', alpha=.01)
  all_x.append(x+noisex)
  all_y.append(y+noisey)

To get a heat diagram, as was suggested, you can use a 2d
histogram.

  plt.figure()
  all_x =np.array(all_x)
  all_y = np.array(all_y)
  all_x.shape = all_y.shape = -1
  H, yedges, xedges = np.histogram2d(all_y, all_x, bins=100)
  extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
  ax = plt.gca()
  plt.hot()
  ax.imshow(H, extent=extent, interpolation='nearest')
  ax.invert_yaxis()

I'm attaching the two images for reference

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<><>--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] [Bug] Bar plot with log scale on y axes

2012-01-23 Thread Álvaro Justen [Turicas]
Hello,
I'm using version 1.0.1 and I think this code snippet and the images
attached are enough to explain the bug:
https://gist.github.com/1667300

Images 'bar-log-bug.png' and 'bar-log-ok.png' must be the same since
it is the same data and same configuration - the bug occurs when we
call set_yscale after calling subplot.bar().

If you confirm the bug, I'll create an issue on GitHub.

Thanks,
-- 
 Álvaro Justen "Turicas"
   http://blog.justen.eng.br http://twitter.com/turicas
   http://CursoDeArduino.com.br http://github.com/turicas
   +55 21 9898-0141
<><>--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [Bug] Bar plot with log scale on y axes

2012-01-23 Thread Benjamin Root
On Monday, January 23, 2012, Álvaro Justen [Turicas] 
wrote:
> Hello,
> I'm using version 1.0.1 and I think this code snippet and the images
> attached are enough to explain the bug:
> https://gist.github.com/1667300
>
> Images 'bar-log-bug.png' and 'bar-log-ok.png' must be the same since
> it is the same data and same configuration - the bug occurs when we
> call set_yscale after calling subplot.bar().
>
> If you confirm the bug, I'll create an issue on GitHub.


This is a known issue and is not a bug.  If you know that you are using log
scale for your bar graph, then it is best to simply specify it in the bar()
command (log=True, I think).  Having bar() work when you call set_yscale()
before bar() is merely a convenience.  Recommended usage is to tell bar()
that you are using log scale so that it can avoid taking the log of zero
(or negative).

Cheers,
Ben Root
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users