Plotting via python

By admin on 21 May | 0 comments

Spent most of the afternoon trying to sort the plotting features in scipy – looks like my problem was that once I called the plot function I also needed to call the show function so the the graph would indeed show on screen. This could be overcome by just inserting the show () function at the bottom of the code segment of the plot function.

Here is some of the code that I managed to get up and running- oh things would have been easier it I had started using matlab instead of python .. good for the soul !!!!

from matplotlib import rcParams
rcParams['text.fontname'] = 'cmr10'
from pylab import *
 
 
mu, sigma = 100, 15
x = mu + sigma*randn(10000)
 
# the histogram of the data
n, bins, patches = hist(x, 100, normed=1)
 
# add a 'best fit' line
y = normpdf( bins, mu, sigma)
l = plot(bins, y, 'r--', linewidth=2)
xlim(40, 160)
 
xlabel('Smarts')
ylabel('P')
title(r'$\rm{IQ:}\/ \mu=100,\/ \sigma=15$')
 
#help(pylab.hist)
#very useful in getting more information that isnt documented very well
 
show()