[Matplotlib-users] Access to contents of bins of a matplotlib histogram

2011-03-25 Thread Chris Edwards
Hi,

I would like to access values in the bins of a matplotlib histogram. The 
following example script is an attempt to do this. Clearly pdf contains 
floating point numbers, but I am unable to access them.

Help with this problem would be much appreciated.

Chris

--
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)

mu, sigma = 100, 15
x = mu + sigma * np.random.randn(20)

#Generate the histogram of the data. Example from Matplotlib documentation

n, bins, patches = plt.hist(x, 50, normed=True, facecolor='g', alpha=0.75)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)

#From Matplotlib documentation.
#normed: If True, the first element of the return tuple will be the counts 
normalized
#to form a probability density, i.e., n/(len(x)*dbin). In a probability density,
#the integral of the histogram should be 1; you can verify that with a 
trapezoidal
#integration of the probability density function.

pdf, bins, patches = ax.hist(x, 50, normed=True, facecolor='g', alpha=0.75)

#print pdf shows pdf contains the value in each bin of the normed histogram

print pdf = , pdf

print  Integration of PDF = , np.sum(pdf * np.diff(bins))

#How to access values in pdf? Various tries made but none successful. Example 
attempt shown

count=0
for line in open(pdf,'r+'):
x=pdf.readline()
z=('%.10f' % float(x))
count=count+1
print count = , count


--
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Can't produce plots using Matplotlib

2011-02-22 Thread Chris Edwards
Recently I downloaded and installed Python(x,y) Version 2.6.5.6 running under 
Windows7 and now can't produce the plots that my programs produced under an 
earlier version of Python(x,y). The programs seem to run correctly and produce 
the same numerical results but I can't find the graphical output (if it exists).
I presume that the problem isn caused by either an incorrect use of Matplotlib, 
an installation issue or my simply misunderstanding the use of Spyder.
I would greatly appreciate some guidance on how to solve this problem.
--
Index, Search  Analyze Logs and other IT data in Real-Time with Splunk 
Collect, index and harness all the fast moving IT data generated by your 
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights. 
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users