[Matplotlib-users] Script hanging during plot of Runge-Kutta

2012-02-19 Thread surfcast23

Hi I wrote the following script, but it hangs right after plt.show(). I would
really appreciate it if someone could take a look and let me know where I'm
messing up. Thanks in advance

from numpy import *
import matplotlib.pyplot as plt

#H=p^2/2-cosq
#p=dp=-dH/dq
#q=dq=dH/dp

t = 0
h = 0.5
pfa = []#Create arrays that will hold pf,qf values
qfa = []

while t < 10:
  q = 1+t
  p = -sin(q+t)

  p1 = p
  q1 = q
  p2 = p + h/2*q1
  q2 = q + h/2*p1
  p3 = p+ h/2*q2
  q3 = q+ h/2*p2
  p4 = p+ h/2*q3
  q4 = q+ h/2*p4
  pf = (p +(h/6)*(p1+2*p2+3*p3+p4))
  qf = (q +(h/6)*(q1+2*q2+3*q3+q4))
  #pf = log10(pf)  #Convert to log scale
  #qf = log10(qf)
  pfa.append(pf)   #append arrays
  qfa.append(qf)
  t += h  #increase time step
  
  print("test")
  plt.plot(pfa,qfa)
  print("test1")
  plt.show()
  print("tes2t")
  
 


-- 
View this message in context: 
http://old.nabble.com/Script-hanging-during-plot-of-Runge-Kutta-tp33354840p33354840.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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plot points in a 3D Scatter Plot

2012-06-11 Thread surfcast23

to matplotlib-use.
Hi,

  I have a data set that is composed of x,y,z coordinates of the center of
cells and counts of objects in each contained in cell. I am using the
following code to do a scatter plot of the counts per cell.


ax = fig.add_subplot(111, projection='3d')
ax.scatter(Xa, Ya, Za, zdir='z', s=C, c='b')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()

Where Xa, Ya, Za, are arrays containing the cell centers, and C is an array
of counts per cell.  Below is a plot I did where the blue circles represent
the  "size in points^2. It is a scalar or an array of the same length as x
and y."(Quote from docs).  What I would like to do is have  the plot show
the actual number of counts as points in the plot. Is such a thing possible?
Thanks

Best,
Khary

http://old.nabble.com/file/p33990025/3D_2.png 
-- 
View this message in context: 
http://old.nabble.com/Plot-points-in-a-3D-Scatter-Plot-tp33990025p33990025.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plot points in a 3D Scatter Plot

2012-06-17 Thread surfcast23

Thanks Ben I will check it out

Benjamin Root-2 wrote:
> 
> Khary,
> 
> On Sun, Jun 10, 2012 at 3:30 PM, surfcast23  wrote:
> 
>>
>> to matplotlib-use.
>> Hi,
>>
>>  I have a data set that is composed of x,y,z coordinates of the center of
>> cells and counts of objects in each contained in cell. I am using the
>> following code to do a scatter plot of the counts per cell.
>>
>>
>> ax = fig.add_subplot(111, projection='3d')
>> ax.scatter(Xa, Ya, Za, zdir='z', s=C, c='b')
>> ax.set_xlabel('X Label')
>> ax.set_ylabel('Y Label')
>> ax.set_zlabel('Z Label')
>> plt.show()
>>
>> Where Xa, Ya, Za, are arrays containing the cell centers, and C is an
>> array
>> of counts per cell.  Below is a plot I did where the blue circles
>> represent
>> the  "size in points^2. It is a scalar or an array of the same length as
>> x
>> and y."(Quote from docs).  What I would like to do is have  the plot show
>> the actual number of counts as points in the plot. Is such a thing
>> possible?
>> Thanks
>>
>> Best,
>> Khary
>>
> 
> I think this example might be what you are looking for:
> 
> http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html#text
> 
> Cheers!
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Plot-points-in-a-3D-Scatter-Plot-tp33990025p34027555.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] IndexError: index out of bounds

2012-07-01 Thread surfcast23

Hi,
  I am translating a Matlab code to python and get the following error when
the codes reaches the plotting section 

Warning (from warnings module):
  File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn.py", line 40
w = (D*v)
RuntimeWarning: overflow encountered in multiply
Traceback (most recent call last):
  File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn\.py", line
50, in 
ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
  File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line
906, in plot_wireframe
tylines = [tY[i] for i in cii]
  File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line
906, in 
tylines = [tY[i] for i in cii]
IndexError: index out of bounds

My code 

import numpy as np
from numpy import *
from math import  pi
from scipy.linalg import toeplitz
from scipy.special import cotdg
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt



N = 512
h = 2*np.pi/N
x = h*(np.arange(N) + 1)
t = 0
dt = h / 4
a = .1
tmax = 15;   
tplot = .15;
nplots = int(round((tmax/tplot)));
plotgap = int(around(tplot/dt));
c = a + np.sin(x - 1)**2
v = np.exp(-100 * (x - 1)**2)
vold = np.exp(-100 * (x - a*dt - 1)**2)

#i = np.arange(1, N)
#column = np.hstack([0, .5 * (-1**i) * cotdg(i * h/2)])
#D = toeplitz(column, -column) 

column = ((0.5*(-1)**arange(1,N+1))*cotdg(arange(1,N+1))*(h/2));
D = toeplitz(column,-column);print(D.shape);
 
k = np.zeros(((nplots,N))); print(v.shape);print(k.shape);
data = np.concatenate((v.reshape((512,1)).transpose(), k))#data =
np.concatenate((v, k),axis = 1);
#data = np.vstack([v,k]);
tdata = t;

for i in range(1,nplots+1):
for n in range(1,plotgap+1):
t = t+dt
w = (D*v)
vnew = vold-2*dt*c*w
vold = v
v = vnew
data[i,:] = v[0,:]
tdata = vstack([tdata, t])
 
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)

plt.show()

I looked at the error line and it seems as if the y axes is where the
problem is, but I am not seeing why and would appreciate any help. Thank
you!
-- 
View this message in context: 
http://old.nabble.com/IndexError%3A-index-out-of-bounds-tp34098663p34098663.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] IndexError: index out of bounds

2012-07-03 Thread surfcast23

I will try initializing starting at 0

Benjamin Root-2 wrote:
> 
> On Sun, Jul 1, 2012 at 12:50 PM, surfcast23  wrote:
> 
>>
>> Hi,
>>   I am translating a Matlab code to python and get the following error
>> when
>> the codes reaches the plotting section
>>
>> Warning (from warnings module):
>>   File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn.py", line
>> 40
>> w = (D*v)
>> RuntimeWarning: overflow encountered in multiply
>> Traceback (most recent call last):
>>   File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn\.py",
>> line
>> 50, in 
>> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
>>   File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py",
>> line
>> 906, in plot_wireframe
>> tylines = [tY[i] for i in cii]
>>   File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py",
>> line
>> 906, in 
>> tylines = [tY[i] for i in cii]
>> IndexError: index out of bounds
>>
>> My code
>>
>> import numpy as np
>> from numpy import *
>> from math import  pi
>> from scipy.linalg import toeplitz
>> from scipy.special import cotdg
>> from mpl_toolkits.mplot3d import axes3d
>> import matplotlib.pyplot as plt
>>
>>
>>
>> N = 512
>> h = 2*np.pi/N
>> x = h*(np.arange(N) + 1)
>> t = 0
>> dt = h / 4
>> a = .1
>> tmax = 15;
>> tplot = .15;
>> nplots = int(round((tmax/tplot)));
>> plotgap = int(around(tplot/dt));
>> c = a + np.sin(x - 1)**2
>> v = np.exp(-100 * (x - 1)**2)
>> vold = np.exp(-100 * (x - a*dt - 1)**2)
>>
>> #i = np.arange(1, N)
>> #column = np.hstack([0, .5 * (-1**i) * cotdg(i * h/2)])
>> #D = toeplitz(column, -column)
>>
>> column = ((0.5*(-1)**arange(1,N+1))*cotdg(arange(1,N+1))*(h/2));
>> D = toeplitz(column,-column);print(D.shape);
>>
>> k = np.zeros(((nplots,N))); print(v.shape);print(k.shape);
>> data = np.concatenate((v.reshape((512,1)).transpose(), k))#data =
>> np.concatenate((v, k),axis = 1);
>> #data = np.vstack([v,k]);
>> tdata = t;
>>
>> for i in range(1,nplots+1):
>> for n in range(1,plotgap+1):
>> t = t+dt
>> w = (D*v)
>> vnew = vold-2*dt*c*w
>> vold = v
>> v = vnew
>> data[i,:] = v[0,:]
>> tdata = vstack([tdata, t])
>>
>> fig = plt.figure()
>> ax = fig.add_subplot(111, projection='3d')
>> #X, Y, Z = axes3d.get_test_data(0.05)
>> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
>>
>> plt.show()
>>
>> I looked at the error line and it seems as if the y axes is where the
>> problem is, but I am not seeing why and would appreciate any help. Thank
>> you!
>>
> 
> numpy arrays are indexed starting at 0, not 1.  So when you populate your
> "data" array with "data[i,:] = v[0,:]", and "i" only goes from 1 to
> nplots,
> data[0,:] is left completely uninitialized (unless it is being done by
> some
> of your pre-for-loop code, which is confusing to understand.)
> 
> What I can tell you is that the error isn't in plot_wireframe() as much as
> the error exist with the inputs to plot_wireframe().  Perhaps the shapes
> aren't right or something.  I will try and look at your code closer
> tomorrow and see if I can figure it out, but I suggest double-checking
> those arrays.
> 
> Cheers!
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/IndexError%3A-index-out-of-bounds-tp34098663p34109116.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-26 Thread surfcast23

Hi 
I have a code to plot a histogram and I am trying to add a best fit line
following this example

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

but run into this error

Traceback (most recent call last):
  File "/home/Astro/count_Histogram.py", line 54, in 
l = plt.plot(bins, y, 'r--', linewidth=1)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467, in
plot
ret = ax.plot(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in plot
for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
_grab_next_args
for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
_plot_args
x, y = self._xy_from_xy(x, y)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
_xy_from_xy
raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

My Code 

import matplotlib.pyplot as plt
import math
import numpy as np
import mpl_toolkits.mplot3d.axes3d
import matplotlib.mlab as mlab

counts = []
F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
f = open(F)
for line in f:
 if line != ' ':  
columns = line.split() 
count = columns[3] 
count = int(count)
counts.append(count)
C  = np.array(counts, dtype=float)

avg = sum(C)/len(C)
diff = C-avg
sigma = np.sqrt((1./len(C))*(diff**2))

bins = 20
plt.hist(C, bins, range=None, normed=False, weights=None, cumulative=False,
bottom=None, histtype='bar', align='mid', orientation='vertical',
rwidth=None, log = False, color=None, label=None)
plt.title("")
plt.text(25,20,'M < -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( bins, avg, sigma)
print(len(y))
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.show()


My first question is do x and y refer to the values in  l = plt.plot(bins,
y, 'r--', linewidth=1) which for my case are bins and y?
if that is the case how can I get then to be the same first dimension?
-- 
View this message in context: 
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23

Hi David,
 
   I tried your fix
nbins = 20
n, bins, patches = plt.hist(C, nbins, range=None, normed=False,
weights=None, cumulative=False, bottom=None, histtype='bar', align='mid',
orientation='vertical', rwidth=None, log = False, color=None, label=None)
plt.title("")
plt.text(25,20,'M < -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( nbins, avg, sigma)
l = plt.plot(nbins, y, 'r--', linewidth=1)
plt.show()


But I am still getting the error. I printed y.shape which gave (216,) so
does that mean that bins also needs to have 216 as a first dimension? Thank
you

Khary


Daπid wrote:
> 
> In the example you provide, bins is returned by the hist command,
> whereas in your code, bins is a number that you defined as 20. So,
> change:
> 
> bins = 20
> plt.hist(C, bins, ...
> 
> by:
> 
> nbins = 20
> n, bins, patches = plt.hist(C, nbins, ...
> 
> 
> As a side comment, your data loading is too complex, and fail prone. I
> suggest you to have a look at the numpy function for that, loadfromtxt
> or (I like it more), genfromtxt. It would be something like:
> 
> data=np.genfromtxt(F, delimiter=' ')
> C=data[:,3]
> 
> Much easier, and way faster.
> 
> 
> Regards,
> 
> David.
> 
> On Fri, Jul 27, 2012 at 4:13 AM, surfcast23  wrote:
>>
>> Hi
>> I have a code to plot a histogram and I am trying to add a best fit line
>> following this example
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo.html
>>
>> but run into this error
>>
>> Traceback (most recent call last):
>>   File "/home/Astro/count_Histogram.py", line 54, in 
>> l = plt.plot(bins, y, 'r--', linewidth=1)
>>   File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467, in
>> plot
>> ret = ax.plot(*args, **kwargs)
>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in
>> plot
>> for line in self._get_lines(*args, **kwargs):
>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
>> _grab_next_args
>> for seg in self._plot_args(remaining, kwargs):
>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
>> _plot_args
>> x, y = self._xy_from_xy(x, y)
>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
>> _xy_from_xy
>> raise ValueError("x and y must have same first dimension")
>> ValueError: x and y must have same first dimension
>>
>> My Code
>>
>> import matplotlib.pyplot as plt
>> import math
>> import numpy as np
>> import mpl_toolkits.mplot3d.axes3d
>> import matplotlib.mlab as mlab
>>
>> counts = []
>> F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
>> f = open(F)
>> for line in f:
>>  if line != ' ':
>> columns = line.split()
>> count = columns[3]
>> count = int(count)
>> counts.append(count)
>> C  = np.array(counts, dtype=float)
>>
>> avg = sum(C)/len(C)
>> diff = C-avg
>> sigma = np.sqrt((1./len(C))*(diff**2))
>>
>> bins = 20
>> plt.hist(C, bins, range=None, normed=False, weights=None,
>> cumulative=False,
>> bottom=None, histtype='bar', align='mid', orientation='vertical',
>> rwidth=None, log = False, color=None, label=None)
>> plt.title("")
>> plt.text(25,20,'M < -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell
>> 38.68Mpc'
>> '\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
>> plt.xlabel("Halos/Cell")
>> plt.ylabel("Number Cells with N Halos")
>> y = mlab.normpdf( bins, avg, sigma)
>> print(len(y))
>> l = plt.plot(bins, y, 'r--', linewidth=1)
>> plt.show()
>>
>>
>> My first question is do x and y refer to the values in  l =
>> plt.plot(bins,
>> y, 'r--', linewidth=1) which for my case are bins and y?
>> if that is the case how can I get then to be the same first dimension?
>> --
>> View this message in context:
>> http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html
>> Sent from the matplotlib - users mailing list archive at Nabble.

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23

Just tried it with nbins set to 216 and I still get the error






surfcast23 wrote:
> 
> Hi David,
>  
>I tried your fix
> nbins = 20
> n, bins, patches = plt.hist(C, nbins, range=None, normed=False,
> weights=None, cumulative=False, bottom=None, histtype='bar', align='mid',
> orientation='vertical', rwidth=None, log = False, color=None, label=None)
> plt.title("")
> plt.text(25,20,'M < -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
> '\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
> plt.xlabel("Halos/Cell")
> plt.ylabel("Number Cells with N Halos")
> y = mlab.normpdf( nbins, avg, sigma)
> l = plt.plot(nbins, y, 'r--', linewidth=1)
> plt.show()
> 
> 
> But I am still getting the error. I printed y.shape which gave (216,) so
> does that mean that bins also needs to have 216 as a first dimension?
> Thank you
> 
> Khary
> 
> 
> Daπid wrote:
>> 
>> In the example you provide, bins is returned by the hist command,
>> whereas in your code, bins is a number that you defined as 20. So,
>> change:
>> 
>> bins = 20
>> plt.hist(C, bins, ...
>> 
>> by:
>> 
>> nbins = 20
>> n, bins, patches = plt.hist(C, nbins, ...
>> 
>> 
>> As a side comment, your data loading is too complex, and fail prone. I
>> suggest you to have a look at the numpy function for that, loadfromtxt
>> or (I like it more), genfromtxt. It would be something like:
>> 
>> data=np.genfromtxt(F, delimiter=' ')
>> C=data[:,3]
>> 
>> Much easier, and way faster.
>> 
>> 
>> Regards,
>> 
>> David.
>> 
>> On Fri, Jul 27, 2012 at 4:13 AM, surfcast23  wrote:
>>>
>>> Hi
>>> I have a code to plot a histogram and I am trying to add a best fit line
>>> following this example
>>>
>>> http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo.html
>>>
>>> but run into this error
>>>
>>> Traceback (most recent call last):
>>>   File "/home/Astro/count_Histogram.py", line 54, in 
>>> l = plt.plot(bins, y, 'r--', linewidth=1)
>>>   File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467,
>>> in
>>> plot
>>> ret = ax.plot(*args, **kwargs)
>>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in
>>> plot
>>> for line in self._get_lines(*args, **kwargs):
>>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
>>> _grab_next_args
>>> for seg in self._plot_args(remaining, kwargs):
>>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
>>> _plot_args
>>> x, y = self._xy_from_xy(x, y)
>>>   File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
>>> _xy_from_xy
>>> raise ValueError("x and y must have same first dimension")
>>> ValueError: x and y must have same first dimension
>>>
>>> My Code
>>>
>>> import matplotlib.pyplot as plt
>>> import math
>>> import numpy as np
>>> import mpl_toolkits.mplot3d.axes3d
>>> import matplotlib.mlab as mlab
>>>
>>> counts = []
>>> F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
>>> f = open(F)
>>> for line in f:
>>>  if line != ' ':
>>> columns = line.split()
>>> count = columns[3]
>>> count = int(count)
>>> counts.append(count)
>>> C  = np.array(counts, dtype=float)
>>>
>>> avg = sum(C)/len(C)
>>> diff = C-avg
>>> sigma = np.sqrt((1./len(C))*(diff**2))
>>>
>>> bins = 20
>>> plt.hist(C, bins, range=None, normed=False, weights=None,
>>> cumulative=False,
>>> bottom=None, histtype='bar', align='mid', orientation='vertical',
>>> rwidth=None, log = False, color=None, label=None)
>>> plt.title("")
>>> plt.text(25,20,'M < -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell
>>> 38.68Mpc'
>>> '\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
>>> plt.xlabel("Halos/Cell")
>>> plt.ylabel("Number Cells with N Halos")
>>> y = mlab.normpdf( bins, avg, sigma)

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23

Thanks for catching that sigma was still a vector! I am no longer getting the
errors, but the best fit line is not showing up.Is there something else I am
missing ?
BTW thanks for the heads up on the np.mean and np.standard functions. 

Khary 

Daπid wrote:
> 
> On Fri, Jul 27, 2012 at 9:57 PM, surfcast23  wrote:
>> y = mlab.normpdf( nbins, avg, sigma)
>> l = plt.plot(nbins, y, 'r--', linewidth=1)
>> plt.show()
> 
> You should not change bins there, as you are evaluating the gaussian
> function at different values.
> 
> Also, sigma is a vector, but it should be an scalar:
> 
> sigma = np.sqrt((1./len(C))*(diff**2))
> 
> should be
> 
> sigma = np.sum(np.sqrt((1./len(C))*(diff**2)))# The sum of the
> previous
> 
> But, much better, you can change the three lines of code by:
> 
> avg=np.mean(C)
> sigma=np.std(C)
> 
> They are way faster and more numerically accurate and stable.
> 
> 
> As a rule of thumb, if you want to do something simple, think that
> there should be an easy way of doing it. And if it is something people
> do every day (like taking the mean or the std of a vector, or loading
> from a txt file), there should be a very easy way of doing it. :-) And
> it would probably be faster and more flexible than any naive
> implementation.
> 
> 
> Good luck with your galaxies!
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222788.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23

That worked beautifully thank you!
Am I reading  (bins[1]-bins[0]) correctly as taking the difference between
what is in the second and first bin?



Daπid wrote:
> 
> I guess it is showing, but you have many data points, so the gaussian
> is too small down there. You have to increase its values to make both
> areas fit:
> 
> plt.plot(bins, N* N*(bins[1]-bins[0])**y, 'r--', linewidth=1)
> 
> 
> And you will get a nice gaussian fitting your data.
> 
> On Fri, Jul 27, 2012 at 11:12 PM, surfcast23  wrote:
>>
>> Thanks for catching that sigma was still a vector! I am no longer getting
>> the
>> errors, but the best fit line is not showing up.Is there something else I
>> am
>> missing ?
>> BTW thanks for the heads up on the np.mean and np.standard functions.
>>
>> Khary
>>
>> Daπid wrote:
>>>
>>> On Fri, Jul 27, 2012 at 9:57 PM, surfcast23 
>>> wrote:
>>>> y = mlab.normpdf( nbins, avg, sigma)
>>>> l = plt.plot(nbins, y, 'r--', linewidth=1)
>>>> plt.show()
>>>
>>> You should not change bins there, as you are evaluating the gaussian
>>> function at different values.
>>>
>>> Also, sigma is a vector, but it should be an scalar:
>>>
>>> sigma = np.sqrt((1./len(C))*(diff**2))
>>>
>>> should be
>>>
>>> sigma = np.sum(np.sqrt((1./len(C))*(diff**2)))# The sum of the
>>> previous
>>>
>>> But, much better, you can change the three lines of code by:
>>>
>>> avg=np.mean(C)
>>> sigma=np.std(C)
>>>
>>> They are way faster and more numerically accurate and stable.
>>>
>>>
>>> As a rule of thumb, if you want to do something simple, think that
>>> there should be an easy way of doing it. And if it is something people
>>> do every day (like taking the mean or the std of a vector, or loading
>>> from a txt file), there should be a very easy way of doing it. :-) And
>>> it would probably be faster and more flexible than any naive
>>> implementation.
>>>
>>>
>>> Good luck with your galaxies!
>>>
>>> --
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond.
>>> Discussions
>>> will include endpoint security, mobile security and the latest in
>>> malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> ___
>>> Matplotlib-users mailing list
>>> Matplotlib-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222788.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222969.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23

Thank you for the help!

Daπid wrote:
> 
> On Sat, Jul 28, 2012 at 12:22 AM, surfcast23  wrote:
>> Am I reading  (bins[1]-bins[0]) correctly as taking the difference
>> between
>> what is in the second and first bin?
> 
> Yes. I am multipliying the width of the bins by their total height.
> Surely there are cleaner and more general ways
> (say, when the bins are of different width), but this one does the
> trick for most cases.
> 
> And, if you have many data points, you can increase the number of bins
> (typically the square root of the number of points, if you have enough
> density)  and get a more precise profile. In that case you would want
> to change the parameter of hist histype='stepfilled'
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34223136.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] IndexError: index out of bounds

2012-07-31 Thread surfcast23

Hi Ben,

  I was working on some other things and have finally gotten a chance to get
back to this. I changed the for loops to

for i in range(nplots):
for n in range(plotgap):
t = t+dt
w = (D*v)
vnew = vold-2*dt*c*w
vold = v
v = vnew
data[i,:] = v[0,:]
tdata = vstack([tdata, t])

But I still get the same error as in my original post.

Khary


surfcast23 wrote:
> 
> I will try initializing starting at 0
> 
> Benjamin Root-2 wrote:
>> 
>> On Sun, Jul 1, 2012 at 12:50 PM, surfcast23  wrote:
>> 
>>>
>>> Hi,
>>>   I am translating a Matlab code to python and get the following error
>>> when
>>> the codes reaches the plotting section
>>>
>>> Warning (from warnings module):
>>>   File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn.py",
>>> line
>>> 40
>>> w = (D*v)
>>> RuntimeWarning: overflow encountered in multiply
>>> Traceback (most recent call last):
>>>   File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn\.py",
>>> line
>>> 50, in 
>>> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
>>>   File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py",
>>> line
>>> 906, in plot_wireframe
>>> tylines = [tY[i] for i in cii]
>>>   File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py",
>>> line
>>> 906, in 
>>> tylines = [tY[i] for i in cii]
>>> IndexError: index out of bounds
>>>
>>> My code
>>>
>>> import numpy as np
>>> from numpy import *
>>> from math import  pi
>>> from scipy.linalg import toeplitz
>>> from scipy.special import cotdg
>>> from mpl_toolkits.mplot3d import axes3d
>>> import matplotlib.pyplot as plt
>>>
>>>
>>>
>>> N = 512
>>> h = 2*np.pi/N
>>> x = h*(np.arange(N) + 1)
>>> t = 0
>>> dt = h / 4
>>> a = .1
>>> tmax = 15;
>>> tplot = .15;
>>> nplots = int(round((tmax/tplot)));
>>> plotgap = int(around(tplot/dt));
>>> c = a + np.sin(x - 1)**2
>>> v = np.exp(-100 * (x - 1)**2)
>>> vold = np.exp(-100 * (x - a*dt - 1)**2)
>>>
>>> #i = np.arange(1, N)
>>> #column = np.hstack([0, .5 * (-1**i) * cotdg(i * h/2)])
>>> #D = toeplitz(column, -column)
>>>
>>> column = ((0.5*(-1)**arange(1,N+1))*cotdg(arange(1,N+1))*(h/2));
>>> D = toeplitz(column,-column);print(D.shape);
>>>
>>> k = np.zeros(((nplots,N))); print(v.shape);print(k.shape);
>>> data = np.concatenate((v.reshape((512,1)).transpose(), k))#data =
>>> np.concatenate((v, k),axis = 1);
>>> #data = np.vstack([v,k]);
>>> tdata = t;
>>>
>>> for i in range(1,nplots+1):
>>> for n in range(1,plotgap+1):
>>> t = t+dt
>>> w = (D*v)
>>> vnew = vold-2*dt*c*w
>>> vold = v
>>> v = vnew
>>> data[i,:] = v[0,:]
>>> tdata = vstack([tdata, t])
>>>
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111, projection='3d')
>>> #X, Y, Z = axes3d.get_test_data(0.05)
>>> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
>>>
>>> plt.show()
>>>
>>> I looked at the error line and it seems as if the y axes is where the
>>> problem is, but I am not seeing why and would appreciate any help. Thank
>>> you!
>>>
>> 
>> numpy arrays are indexed starting at 0, not 1.  So when you populate your
>> "data" array with "data[i,:] = v[0,:]", and "i" only goes from 1 to
>> nplots,
>> data[0,:] is left completely uninitialized (unless it is being done by
>> some
>> of your pre-for-loop code, which is confusing to understand.)
>> 
>> What I can tell you is that the error isn't in plot_wireframe() as much
>> as
>> the error exist with the inputs to plot_wireframe().  Perhaps the shapes
>> aren't right or something.  I will try and look at your code closer
>> tomorrow and see if I can figure it out, but I suggest double-checking
>> those arrays.
>> 
>> Cheers!
>> Ben Root
>> 
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and 
>> threat landscape has changed and how

Re: [Matplotlib-users] IndexError: index out of bounds

2012-07-31 Thread surfcast23

I also got the dimensions of the arrays and was wandering if the problem
might be there

shape data = (101, 512) 
shape v = (512, 512) 
shape tdata = (101, 1) 
shape x = (512,)



Benjamin Root-2 wrote:
> 
> On Sun, Jul 1, 2012 at 12:50 PM, surfcast23  wrote:
> 
>>
>> Hi,
>>   I am translating a Matlab code to python and get the following error
>> when
>> the codes reaches the plotting section
>>
>> Warning (from warnings module):
>>   File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn.py", line
>> 40
>> w = (D*v)
>> RuntimeWarning: overflow encountered in multiply
>> Traceback (most recent call last):
>>   File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn\.py",
>> line
>> 50, in 
>> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
>>   File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py",
>> line
>> 906, in plot_wireframe
>> tylines = [tY[i] for i in cii]
>>   File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py",
>> line
>> 906, in 
>> tylines = [tY[i] for i in cii]
>> IndexError: index out of bounds
>>
>> My code
>>
>> import numpy as np
>> from numpy import *
>> from math import  pi
>> from scipy.linalg import toeplitz
>> from scipy.special import cotdg
>> from mpl_toolkits.mplot3d import axes3d
>> import matplotlib.pyplot as plt
>>
>>
>>
>> N = 512
>> h = 2*np.pi/N
>> x = h*(np.arange(N) + 1)
>> t = 0
>> dt = h / 4
>> a = .1
>> tmax = 15;
>> tplot = .15;
>> nplots = int(round((tmax/tplot)));
>> plotgap = int(around(tplot/dt));
>> c = a + np.sin(x - 1)**2
>> v = np.exp(-100 * (x - 1)**2)
>> vold = np.exp(-100 * (x - a*dt - 1)**2)
>>
>> #i = np.arange(1, N)
>> #column = np.hstack([0, .5 * (-1**i) * cotdg(i * h/2)])
>> #D = toeplitz(column, -column)
>>
>> column = ((0.5*(-1)**arange(1,N+1))*cotdg(arange(1,N+1))*(h/2));
>> D = toeplitz(column,-column);print(D.shape);
>>
>> k = np.zeros(((nplots,N))); print(v.shape);print(k.shape);
>> data = np.concatenate((v.reshape((512,1)).transpose(), k))#data =
>> np.concatenate((v, k),axis = 1);
>> #data = np.vstack([v,k]);
>> tdata = t;
>>
>> for i in range(1,nplots+1):
>> for n in range(1,plotgap+1):
>> t = t+dt
>> w = (D*v)
>> vnew = vold-2*dt*c*w
>> vold = v
>> v = vnew
>> data[i,:] = v[0,:]
>> tdata = vstack([tdata, t])
>>
>> fig = plt.figure()
>> ax = fig.add_subplot(111, projection='3d')
>> #X, Y, Z = axes3d.get_test_data(0.05)
>> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10)
>>
>> plt.show()
>>
>> I looked at the error line and it seems as if the y axes is where the
>> problem is, but I am not seeing why and would appreciate any help. Thank
>> you!
>>
> 
> numpy arrays are indexed starting at 0, not 1.  So when you populate your
> "data" array with "data[i,:] = v[0,:]", and "i" only goes from 1 to
> nplots,
> data[0,:] is left completely uninitialized (unless it is being done by
> some
> of your pre-for-loop code, which is confusing to understand.)
> 
> What I can tell you is that the error isn't in plot_wireframe() as much as
> the error exist with the inputs to plot_wireframe().  Perhaps the shapes
> aren't right or something.  I will try and look at your code closer
> tomorrow and see if I can figure it out, but I suggest double-checking
> those arrays.
> 
> Cheers!
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/IndexError%3A-index-out-of-bounds-tp34098663p34238189.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-01 Thread surfcast23

In the documentation it says that Axes3D.plot_wireframe(X, Y, Z, *args,
**kwargs) takes 2D arrays as the first two arguments. Do the arrays have to
have the same size dimensions? 

-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34243823.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-02 Thread surfcast23



surfcast23 wrote:
> 
> In the documentation it says that Axes3D.plot_wireframe(X, Y, Z, *args,
> **kwargs) takes 2D arrays as the first two arguments. Do the arrays have
> to have the same size dimensions? 
> 
> 

Any one know?
-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34248559.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-02 Thread surfcast23

Okay thank you! The Matlab code I am basing this on takes arrays of different
shapes with different  sized elements ie 
x =  1   512
y = 101 1
and I guess automatically makes the the same shape. Can you point me in the
direction of documentation that will explain how I can do this in Python?

 

Benjamin Root-2 wrote:
> 
> On Thursday, August 2, 2012, surfcast23 wrote:
> 
>>
>>
>>
>> surfcast23 wrote:
>> >
>> > In the documentation it says that Axes3D.plot_wireframe(X, Y, Z, *args,
>> > **kwargs) takes 2D arrays as the first two arguments. Do the arrays
>> have
>> > to have the same size dimensions?
>> >
>> >
>>
>> Any one know?
> 
> 
> Working from memory, the first two have to at least be "broadcastable"
> into
> the shape of Z.  But absolutely, if x, y, and z are 2d, they have to be
> the
> same shape. It makes no sense otherwise.
> 
> Cheers!
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34248914.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-02 Thread surfcast23

Wouldn't

X= np.ones((1, 45))
Y= np.zeros((32, 1))

change the existing values of the elements to ones and zeros? 


Benjamin Root-2 wrote:
> 
> On Thursday, August 2, 2012, surfcast23 wrote:
> 
>>
>> Okay thank you! The Matlab code I am basing this on takes arrays of
>> different
>> shapes with different  sized elements ie
>> x =  1   512
>> y = 101 1
>> and I guess automatically makes the the same shape. Can you point me in
>> the
>> direction of documentation that will explain how I can do this in Python?
>>
>>
> Ok, I just double-checked the source for plot_wireframe().  It does not
> perform any broadcasting (which I consider to be a bug).
> 
> Until it is fixed, you will have to do the broadcasting yourself:
> 
> X= np.ones((1, 45))
> Y= np.zeros((32, 1))
> x, y = np.broadcast_arrays(X, Y)
> 
> Which produces x and y with the same shapes, and their values duplicated
> in
> the direction the array was "expanded".
> 
> Pass those into plot_wireframe().
> 
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34249151.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-02 Thread surfcast23

sorry misssed this line "Which produces x and y with the same shapes, and
their values duplicated in
the direction the array was "expanded"."

surfcast23 wrote:
> 
> Wouldn't
> 
> X= np.ones((1, 45))
> Y= np.zeros((32, 1))
> 
> change the existing values of the elements to ones and zeros? 
> 
> 
> Benjamin Root-2 wrote:
>> 
>> On Thursday, August 2, 2012, surfcast23 wrote:
>> 
>>>
>>> Okay thank you! The Matlab code I am basing this on takes arrays of
>>> different
>>> shapes with different  sized elements ie
>>> x =  1   512
>>> y = 101 1
>>> and I guess automatically makes the the same shape. Can you point me in
>>> the
>>> direction of documentation that will explain how I can do this in
>>> Python?
>>>
>>>
>> Ok, I just double-checked the source for plot_wireframe().  It does not
>> perform any broadcasting (which I consider to be a bug).
>> 
>> Until it is fixed, you will have to do the broadcasting yourself:
>> 
>> X= np.ones((1, 45))
>> Y= np.zeros((32, 1))
>> x, y = np.broadcast_arrays(X, Y)
>> 
>> Which produces x and y with the same shapes, and their values duplicated
>> in
>> the direction the array was "expanded".
>> 
>> Pass those into plot_wireframe().
>> 
>> Ben Root
>> 
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and 
>> threat landscape has changed and how IT managers can respond. Discussions 
>> will include endpoint security, mobile security and the latest in malware 
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34249160.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-02 Thread surfcast23

I tested it out and it does change all the values to ones and zeros. Is there
a way to broadcast and keep the original values that were in the arrays?
Thanks for the help



Benjamin Root-2 wrote:
> 
> On Thursday, August 2, 2012, surfcast23 wrote:
> 
>>
>> Okay thank you! The Matlab code I am basing this on takes arrays of
>> different
>> shapes with different  sized elements ie
>> x =  1   512
>> y = 101 1
>> and I guess automatically makes the the same shape. Can you point me in
>> the
>> direction of documentation that will explain how I can do this in Python?
>>
>>
> Ok, I just double-checked the source for plot_wireframe().  It does not
> perform any broadcasting (which I consider to be a bug).
> 
> Until it is fixed, you will have to do the broadcasting yourself:
> 
> X= np.ones((1, 45))
> Y= np.zeros((32, 1))
> x, y = np.broadcast_arrays(X, Y)
> 
> Which produces x and y with the same shapes, and their values duplicated
> in
> the direction the array was "expanded".
> 
> Pass those into plot_wireframe().
> 
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34249203.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Size of array elements when using Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

2012-08-02 Thread surfcast23

Gotcha ya working perfectly now thank you for the help!

Benjamin Root-2 wrote:
> 
> On Thursday, August 2, 2012, surfcast23 wrote:
> 
>>
>> Wouldn't
>>
>> X= np.ones((1, 45))
>> Y= np.zeros((32, 1))
>>
>> change the existing values of the elements to ones and zeros?
>>
>>
> I was just demonstrating what np.broadcast_arrays() does.  Take your x and
> y arrays and put them through this function and put the outputs into
> plot_wireframe().  Ignore the ones() and zeros().
> 
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Size-of-array-elements-when-using-Axes3D.plot_wireframe%28X%2C-Y%2C-Z%2C-*args%2C-**kwargs%29-tp34243823p34249265.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Set Histogram bin size to change by interger value

2012-08-12 Thread surfcast23
Hi All,

  I would like to know if there is a way to have the bin sizes change by
integer values. For example the bin size would be
 10-20
 20-30

not 

10.3-20.5
20.3-30.5

and have it adjust as the number of bins changes.
Thanks 



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Set-Histogram-bin-size-to-change-by-interger-value-tp38499.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How do you Plot data generated by a python script?

2011-08-24 Thread surfcast23

I am fairly new to programing and have a question regarding matplotlib. I
wrote a python script that reads in data from the outfile of another program
then prints out the data from one column.

f = open( 'myfile.txt','r')
for line in f:
if line != ' ':
 line = line.strip()   # Strips end of line character 
 columns = line.split() # Splits into coloumn 
 mass = columns[8]# Column which contains mass values 
 print(mass)

What I now need to do is have matplotlib take the values printed in 'mass'
and plot number versus mean mass. I have read the documents on the
matplotlib website, but they don't really address how to get data from a
script(or I just did not see it) If anyone can point me to some
documentation that explains how I do this it would be really appreciated.
 Thanks in advance

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32328822.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-24 Thread surfcast23

Thank you Gary. I will definitely read the numpy doucs 

Gary Ruben-2 wrote:
> 
> As you show it, mass will be a string, so you'll need to convert it to
> a float first, then add it to a list. You can then manipulate the
> values in the list to compute your mean, or whatever, which matplotlib
> can use as input to its plot() function or whichever type of plot
> you're after. Alternatively, since the Python numpy module is made for
> manipulating data like this, it can probably read your data in a
> single function call and easily compute the things you want. However,
> if you are really that new to programming, you may struggle, so I'd
> suggest reading first going to scipy.org and reading up on numpy. When
> you understand the basics of numpy, matplotlib's documentation should
> make a lot more sense.
> 
> Gary
> 
> On Thu, Aug 25, 2011 at 6:48 AM, surfcast23  wrote:
>>
>> I am fairly new to programing and have a question regarding matplotlib. I
>> wrote a python script that reads in data from the outfile of another
>> program
>> then prints out the data from one column.
>>
>> f = open( 'myfile.txt','r')
>> for line in f:
>> if line != ' ':
>>  line = line.strip()       # Strips end of line character
>>  columns = line.split() # Splits into coloumn
>>  mass = columns[8]    # Column which contains mass values
>>  print(mass)
>>
>> What I now need to do is have matplotlib take the values printed in
>> 'mass'
>> and plot number versus mean mass. I have read the documents on the
>> matplotlib website, but they don't really address how to get data from a
>> script(or I just did not see it) If anyone can point me to some
>> documentation that explains how I do this it would be really appreciated.
>>  Thanks in advance
>>
>> --
>> View this message in context:
>> http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32328822.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> --
>> EMC VNX: the world's simplest storage, starting under $10K
>> The only unified storage solution that offers unified management
>> Up to 160% more powerful than alternatives and 25% more efficient.
>> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> --
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management 
> Up to 160% more powerful than alternatives and 25% more efficient. 
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32330761.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-25 Thread surfcast23

Hi Martin,

 Thank for the relpy.  What I have is a script that reads the data from
a large file then prints out the values listed in a particular column. What
I now need to do is have the information in that column plotted as the
number of rows vs. the mean value of all of the rows. What I have so far is 

import matplotlib.pyplot as plt

masses = []

f = open( 'myfile.txt','r')
f.readline()
for line in f:
 if line != ' ':  
line = line.strip()  # Strips end of line character 
columns = line.split()# Splits into coloumn 
mass = columns[8]  # Column which contains mass values
mass = float(mass)
masses.append(mass)
print(mass)

plt.plot()
plt.show


I am thinking I can do something like 

'y runs fron 0 to n where n == len(masses) '
x = 'mass_avg = sum(masses)/len(masses)'

Problem is I don' tknow how to have matplotlib do it with out giving me an
error about dimentions. I would also like to do this with out having to
write and read from another file. I alos need to to be able to work on files
with ddifering numbers of rows.

Thanks





mdekauwe wrote:
> 
> I wasn't quite able to follow exactly what you wanted to do but maybe this
> will help. I am going to generate some "data" that I think sounds a bit
> like yours, write it to a file, clearly you already have this. Then I am
> going to read it back in and plot it, e.g.
> 
> import matplotlib.pyplot as plt
> import numpy as np
> 
> # Generate some data a little like yours, I think? 
> # print it to a file, i.e. I am making your myfile.txt
> numrows = 100
> numcols = 8
> mass = np.random.normal(0, 1, (numrows  * numcols)).reshape(numrows,
> numcols)
> f = open("myfile.txt", "w")
> for i in xrange(numrows):
> for j in xrange(numcols):
> print >>f,  mass[i,j],
> print >> f
> f.close()
> 
> # read the file back in
> mass = np.loadtxt("myfile.txt")
> 
> # plot the 8th column
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(mass[:,7], 'r-o')
> ax.set_xlabel("Time")
> ax.set_ylabel("Mass")
> plt.show()
> 
> 
> I wasn't clear on the mean bit, but that is easy to do with numpy, e.g. 
> 
> mean_mass = np.mean(mass[:,8])
> 
> etc.
> 
> Numpy et al is great for stuff like this.
> 
> Hope that helps,
> 
> Martin
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32336570.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-25 Thread surfcast23

Hi,

   I apologize if my explanation was less than clear. What I have is data in
a column that runs from row 1 to row 1268. In each each row there is a
number. For example

1
3
5
6
7
8
9

so I want  the y axis to run from 1 to 7 ( the number of rows) and the x
axis to be the average of the values in this case 5.57. I am having problems
with setting up the y-axis as well as the dimension   problem you addressed. 

 Is there a way I could have every value on the x axis the same? Say for the
above example have the x and y axis  be

7
6
5
4
3
2
1 
  5.75 5.57 5.57 5.75 5.57 5.57 5.75

 Which would be the number of rows vs the average value of the data in the
rows and then plot that?

Thanks again

Khary



mdekauwe wrote:
> 
> Hi,
> 
> Well the first bit about wanting a specific column and the last bit about
> not wanting to print all the data in and read it back, you get that from
> the example I gave you. If you paste what I wrote for you line by line it
> should become clearer for you, additionally it avoids you have to write
> your own parsing code.
> 
> As far as your plotting goes, unless you actually post what you are
> entering in the script (exactly as you have it), then it is impossible to
> say. For example
> 
> plt.plot()
> plt.show
> 
> there is no way that is all you have? if it is, then of course you will
> get a fail as you are asking matplotlib to plot but are not providing it
> with any data to plot!
> 
> Perhaps I am being particularly dense but "What I now need to do is have
> the information in that column plotted as the number of rows vs. the mean
> value of all of the rows." means nothing to me. Sorry. What do you want on
> the X and Y... do you mean you want to plot your individual column (8 i
> think you called it) against the mean of all the other rows? If so I would
> expect you would have a dimensions issue
> 
> Martin
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32338750.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-25 Thread surfcast23

Hi Ryan,

 I think your solution will work thank you!! I did get an error though it is

"   f.next()# You want to skip the first line, I guess.
AttributeError: '_io.TextIOWrapper' object has no attribute 'next' "

thank you 

Khary


rcnelson wrote:
> 
> If I understand your question correctly, I may have a solution to your
> problem. First of all, the statement below, when converted to Python
> code, will generate an array of numbers the same length of your masses
> list.
>> 'y runs fron 0 to n where n == len(masses) '
> However, this statement will give you a single number:
>> x = 'mass_avg = sum(masses)/len(masses)'
> You will not be able to plot these two objects because of the different
> sizes. If you are asking about a 'running' or cumulative mean, then you
> may
> want to use the cumulative sum function from Numpy (cumsum). To convert
> this
> into a cumulative average, you can do a simple division.
> 
> Below is a modification to your script that incorporates this averaging
> technique. (I don't know why you want to print everything. Surely you
> can't
> see all of the data as the file gets processed. It is also a very slow
> operation... I'll just ignore those parts.)
> 
> import numpy as np
> import matplotlib.pyplot as plt
> f = open('myfile.txt')
> f.next()# You want to skip the first line, I guess.
> mass = []
> for line in f:
> # This will skip the lines that are spaces.
> if line.isspace(): continue
> # The strip function is unnecessary. The defalut for the split
> function
> takes care of that.
> columns = line.split()
> # Don't call the float function every time. It's a waste.
> mass.append( columns[8] )
> # Here we can convert the list of strings into an array of floats with the
> dtype keyword.
> mass = np.array( mass, dtype='float')
> # Here's the cumulative average steps.
> mass_sum = np.cumsum(mass)
> mass_average = mass_sum/ np.arange(1, len(mass_sum) + 1)
> # If you only plot one array or list of values, they are assumed to be the
> y
> values.
> # The x values in that case are the indices of the y value array.
> plt.plot(mass_average)
> plt.show()
> 
> 
> Ryan
> 
> 
>> Message: 5
>> Date: Thu, 25 Aug 2011 11:15:57 -0700 (PDT)
>> From: surfcast23 
>> Subject: Re: [Matplotlib-users] How do you Plot data generated by a
>>python script?
>> To: matplotlib-users@lists.sourceforge.net
>> Message-ID: <32336570.p...@talk.nabble.com>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> Hi Martin,
>>
>> Thank for the relpy.  What I have is a script that reads the data
>> from
>> a large file then prints out the values listed in a particular column.
>> What
>> I now need to do is have the information in that column plotted as the
>> number of rows vs. the mean value of all of the rows. What I have so far
>> is
>>
>> import matplotlib.pyplot as plt
>>
>> masses = []
>>
>> f = open( 'myfile.txt','r')
>> f.readline()
>> for line in f:
>>  if line != ' ':
>>line = line.strip()  # Strips end of line character
>>columns = line.split()# Splits into coloumn
>>mass = columns[8]  # Column which contains mass values
>>mass = float(mass)
>>masses.append(mass)
>>print(mass)
>>
>> plt.plot()
>> plt.show
>>
>>
>> I am thinking I can do something like
>>
>> 'y runs fron 0 to n where n == len(masses) '
>> x = 'mass_avg = sum(masses)/len(masses)'
>>
>> Problem is I don' tknow how to have matplotlib do it with out giving me
>> an
>> error about dimentions. I would also like to do this with out having to
>> write and read from another file. I alos need to to be able to work on
>> files
>> with ddifering numbers of rows.
>>
>> Thanks
>>
>>
>>
>>
>>
>> mdekauwe wrote:
>> >
>> > I wasn't quite able to follow exactly what you wanted to do but maybe
>> this
>> > will help. I am going to generate some "data" that I think sounds a bit
>> > like yours, write it to a file, clearly you already have this. Then I
>> am
>> > going to read it back in and plot it, e.g.
>> >
>> > import matplotlib.pyplot as plt
>> > import numpy as np
>> >
>> > # Generate some data a little like yours, I think?
>> > # print it to a file, i.e. I am making 

Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-25 Thread surfcast23

Hi,

   there is only one column. so I want a plot of y and x. With y taking
values running from 0 to n  or 7 in my example and x as the average of the
values that are contained in the rows in my example it was 5.57.



mdekauwe wrote:
> 
> still don't quite get this, so you want for each column the average? and
> you want to plot each of these averages? So a bar graph? with 8 bars?
> 
> 
> 
> surfcast23 wrote:
>> 
>> Hi,
>> 
>>I apologize if my explanation was less than clear. What I have is data
>> in a column that runs from row 1 to row 1268. In each each row there is a
>> number. For example
>> 
>> 1
>> 3
>> 5
>> 6
>> 7
>> 8
>> 9
>> 
>> so I want  the y axis to run from 1 to 7 ( the number of rows) and the x
>> axis to be the average of the values in this case 5.57. I am having
>> problems with setting up the y-axis as well as the dimension   problem
>> you addressed. 
>> 
>>  Is there a way I could have every value on the x axis the same? Say for
>> the above example have the x and y axis  be
>> 
>> 7
>> 6
>> 5
>> 4
>> 3
>> 2
>> 1 
>>   5.75 5.57 5.57 5.75 5.57 5.57 5.75
>> 
>>  Which would be the number of rows vs the average value of the data in
>> the rows and then plot that?
>> 
>> Thanks again
>> 
>> Khary
>> 
>> 
>> 
>> mdekauwe wrote:
>>> 
>>> Hi,
>>> 
>>> Well the first bit about wanting a specific column and the last bit
>>> about not wanting to print all the data in and read it back, you get
>>> that from the example I gave you. If you paste what I wrote for you line
>>> by line it should become clearer for you, additionally it avoids you
>>> have to write your own parsing code.
>>> 
>>> As far as your plotting goes, unless you actually post what you are
>>> entering in the script (exactly as you have it), then it is impossible
>>> to say. For example
>>> 
>>> plt.plot()
>>> plt.show
>>> 
>>> there is no way that is all you have? if it is, then of course you will
>>> get a fail as you are asking matplotlib to plot but are not providing it
>>> with any data to plot!
>>> 
>>> Perhaps I am being particularly dense but "What I now need to do is have
>>> the information in that column plotted as the number of rows vs. the
>>> mean value of all of the rows." means nothing to me. Sorry. What do you
>>> want on the X and Y... do you mean you want to plot your individual
>>> column (8 i think you called it) against the mean of all the other rows?
>>> If so I would expect you would have a dimensions issue
>>> 
>>> Martin
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32338836.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-25 Thread surfcast23

No problem thanks for helping

mdekauwe wrote:
> 
> Perhaps someone else can help as I feel I am being particularly dense.
> 
> for i in xrange(numcols):
> ax.plot([np.mean(mass[:,7]) for i in xrange(numcols)], 
> np.arange(numcols), label=i) 
> 
> This gives you what I think you said, but really don't think this is what
> you mean as it seems a strange thing to want to do.
> 
> sorry i couldn't be of more help
> 
> 
> surfcast23 wrote:
>> 
>> Hi,
>> 
>>there is only one column. so I want a plot of y and x. With y taking
>> values running from 0 to n  or 7 in my example and x as the average of
>> the values that are contained in the rows in my example it was 5.57.
>> 
>> 
>> 
>> mdekauwe wrote:
>>> 
>>> still don't quite get this, so you want for each column the average? and
>>> you want to plot each of these averages? So a bar graph? with 8 bars?
>>> 
>>> 
>>> 
>>> surfcast23 wrote:
>>>> 
>>>> Hi,
>>>> 
>>>>I apologize if my explanation was less than clear. What I have is
>>>> data in a column that runs from row 1 to row 1268. In each each row
>>>> there is a number. For example
>>>> 
>>>> 1
>>>> 3
>>>> 5
>>>> 6
>>>> 7
>>>> 8
>>>> 9
>>>> 
>>>> so I want  the y axis to run from 1 to 7 ( the number of rows) and the
>>>> x axis to be the average of the values in this case 5.57. I am having
>>>> problems with setting up the y-axis as well as the dimension   problem
>>>> you addressed. 
>>>> 
>>>>  Is there a way I could have every value on the x axis the same? Say
>>>> for the above example have the x and y axis  be
>>>> 
>>>> 7
>>>> 6
>>>> 5
>>>> 4
>>>> 3
>>>> 2
>>>> 1 
>>>>   5.75 5.57 5.57 5.75 5.57 5.57 5.75
>>>> 
>>>>  Which would be the number of rows vs the average value of the data in
>>>> the rows and then plot that?
>>>> 
>>>> Thanks again
>>>> 
>>>> Khary
>>>> 
>>>> 
>>>> 
>>>> mdekauwe wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> Well the first bit about wanting a specific column and the last bit
>>>>> about not wanting to print all the data in and read it back, you get
>>>>> that from the example I gave you. If you paste what I wrote for you
>>>>> line by line it should become clearer for you, additionally it avoids
>>>>> you have to write your own parsing code.
>>>>> 
>>>>> As far as your plotting goes, unless you actually post what you are
>>>>> entering in the script (exactly as you have it), then it is impossible
>>>>> to say. For example
>>>>> 
>>>>> plt.plot()
>>>>> plt.show
>>>>> 
>>>>> there is no way that is all you have? if it is, then of course you
>>>>> will get a fail as you are asking matplotlib to plot but are not
>>>>> providing it with any data to plot!
>>>>> 
>>>>> Perhaps I am being particularly dense but "What I now need to do is
>>>>> have the information in that column plotted as the number of rows vs.
>>>>> the mean value of all of the rows." means nothing to me. Sorry. What
>>>>> do you want on the X and Y... do you mean you want to plot your
>>>>> individual column (8 i think you called it) against the mean of all
>>>>> the other rows? If so I would expect you would have a dimensions issue
>>>>> 
>>>>> Martin
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32338914.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-08-25 Thread surfcast23

Sorry everyone I totally missed something very important. What I need to do
is first bin the masses(which I don't know how to do). 

Chelonian wrote:
> 
> On Thu, Aug 25, 2011 at 10:01 PM, surfcast23  wrote:
>>
>> Hi,
>>
>>   there is only one column. so I want a plot of y and x. With y taking
>> values running from 0 to n  or 7 in my example and x as the average of
>> the
>> values that are contained in the rows in my example it was 5.57.
> 
> It seems to me that, as described, you want a plot that in which all
> the bars are the same height (or width if it is a sideways bar chart),
> in this case, 5.57.  That makes no sense.
> 
> What information is this plot is intended to provide the viewer?
> 
> --
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management 
> Up to 160% more powerful than alternatives and 25% more efficient. 
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32339216.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-09-03 Thread surfcast23

Hi Martin,
 
  Sorry I am just responding. I have been busy getting ready for the
semester. What I need to do is first sort the values contained in the column
and assign them to bins. I then have to plot the number of bins by the mean
value in each bin. 



mdekauwe wrote:
> 
> Can you describe what you want to do? So you now want a histogram?
> 
> 
> surfcast23 wrote:
>> 
>> Sorry everyone I totally missed something very important. What I need to
>> do is first bin the masses(which I don't know how to do). 
>> 
>> Chelonian wrote:
>>> 
>>> On Thu, Aug 25, 2011 at 10:01 PM, surfcast23 
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>>   there is only one column. so I want a plot of y and x. With y taking
>>>> values running from 0 to n  or 7 in my example and x as the average of
>>>> the
>>>> values that are contained in the rows in my example it was 5.57.
>>> 
>>> It seems to me that, as described, you want a plot that in which all
>>> the bars are the same height (or width if it is a sideways bar chart),
>>> in this case, 5.57.  That makes no sense.
>>> 
>>> What information is this plot is intended to provide the viewer?
>>> 
>>> --
>>> EMC VNX: the world's simplest storage, starting under $10K
>>> The only unified storage solution that offers unified management 
>>> Up to 160% more powerful than alternatives and 25% more efficient. 
>>> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>>> ___
>>> Matplotlib-users mailing list
>>> Matplotlib-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32393079.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-09-06 Thread surfcast23

Thanks for everyone responses and help
  
Che,

 You are correct on what I have to do. The problem is that I have a data set
with ~1250 so I cant' do the sorting or finding the mean by hand. I guess
what I need to to is to write a script that will sort the values, bin them,
and keep track of the number of values in each bin. Then find the mean value
in each bin. Then the scrip has to take the number of values in each bin and
plot that versus the mean of each bin. I apologies for the lack of clarity
in my earlier posts. It was unclear to me what exactly had to be done until
this weekend. 

 
 

Chelonian wrote:
> 
> On Sat, Sep 3, 2011 at 7:32 PM, mdekauwe  wrote:
>>
>> So you do want a histogram then? I assume you have all of this sorted
>> then,
>> the histogram function is very good.
> 
> I don't think he's describing a histogram, because he is not plotting
> frequency of observations on the y axis, but data values (means of
> each bin).  I think what surfcast23 wants is just a bar graph.
> 
> So, surfcast23, I'd suggest you break it down into your two steps.
> First, how will you average your values by bin?  You can probably
> figure that out by writing it out on paper in pseudo-code and then
> just putting it in Python. Then you'll have a list of means, and you
> will pass that to the bar function in matplotlib, something like:
> 
> from pylab import *
> ax = subplot(111)
> x = arange(4)
> your_list_of_means = [4,5,7,11] #computed earlier
> bar(x, your_list_of_means)
> xticks( x + 0.5,  ('Bin1', 'Bin2', 'Bin3', 'Bin4') )
> show()
> 
> Che
> 
> --
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better 
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32409886.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do you Plot data generated by a python script?

2011-09-06 Thread surfcast23



Benjamin Root-2 wrote:
> 
> On Tue, Sep 6, 2011 at 12:01 PM, surfcast23  wrote:
> 
>>
>> Thanks for everyone responses and help
>>
>> Che,
>>
>>  You are correct on what I have to do. The problem is that I have a data
>> set
>> with ~1250 so I cant' do the sorting or finding the mean by hand. I guess
>> what I need to to is to write a script that will sort the values, bin
>> them,
>> and keep track of the number of values in each bin. Then find the mean
>> value
>> in each bin. Then the scrip has to take the number of values in each bin
>> and
>> plot that versus the mean of each bin. I apologies for the lack of
>> clarity
>> in my earlier posts. It was unclear to me what exactly had to be done
>> until
>> this weekend.
>>
>>
>>
> I think you really need to read up on the NumPy documentation.  There are
> functions that will do this for you.  NumPy can load/save data, sort them,
> bin them, find means and standard deviations, etc...  You don't need to
> re-invent the wheel.
> 
> Plus, you keep on talking about having a script for each part.  While it
> is
> great that you like modularity, Python does support the use of functions,
> and I would encourage you to use them.
> 
> Cheers,
> Ben Root
> 
> --
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better 
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 


Hi Ben,

  I will read up the numpy docs when I get some time. I am only writing one
script that will do everything sorry if I gave the impression of having
multiple scripts. 

-- 
View this message in context: 
http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32410694.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Malware Security Report: Protecting Your Business, Customers, and the 
Bottom Line. Protect your business and customers by understanding the 
threat from malware and how it can impact your online business. 
http://www.accelacomm.com/jaw/sfnl/114/51427462/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users