Can't create graphs

Hello,

I am completely new to Matplotlib. I can’t seem to get my script (a copy and paste from a Histogram example) to generate a graph. When I run my script, the command prompt returns.

Is there something I am missing?

···

histogram.py

import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

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

the histogram of the data

n, bins, patches = plt.hist(x, 50, normed=1, facecolor=‘green’, alpha=0.75)

add a ‘best fit’ line

y = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, y, ‘r–’, linewidth=1)

plt.xlabel(‘Smarts’)
plt.ylabel(‘Probability’)
plt.title(r’$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$’)
plt.axis([40, 160, 0, 0.03])
plt.grid(True)

plt.show()

Calling with:
python histogram.py

Make sure yu're using a backend with a user interface.

http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend

···

El mié, 19-11-2008 a las 10:49 -0500, Ron Brennan escribió:

Hello,

I am completely new to Matplotlib. I can't seem to get my script (a
copy and paste from a Histogram example) to generate a graph. When I
run my script, the command prompt returns.

Is there something I am missing?

#
# histogram.py
#
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

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

# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green',
alpha=0.75)

# add a 'best fit' line
y = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, y, 'r--', linewidth=1)

plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'\\mathrm\{Histogram\\ of\\ IQ:\}\\ \\mu=100,\\ \\sigma=15')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)

plt.show()

Calling with:
python histogram.py
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options

Make sure yu're using a backend with a user interface.

http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend

Also, you can get more verbose input at runtime with the --verbose-helpful flag:

python histogram.py --verbose-helpful

This will tell you what backend you are running, where your
matplotlibrc file is (which controls the backend), etc. See also

  http://matplotlib.sourceforge.net/faq/installing_faq.html

JDH

···

On Wed, Nov 19, 2008 at 1:22 PM, Goyo <goyodiaz@...287...> wrote: