python - Getting matplotlib to work - plots not showing -


i able install matplotlib; however, when run code, don't error, instead python icon bouncing on , on again.

python

i don't know if has

from rcparamssettings import * 

i don't have idea is, if try run line uncommented out,

importerror: no module named rcparamssettings 

here's code i'm trying run:

import pylab #from rcparamssettings import * import random  def flipplot(minexp, maxexp):     """assumes minexp , maxexp positive integers; minexp < maxexp        plots results of 2**minexp 2**maxexp coin flips"""     ratios = []     diffs = []     xaxis = []     exp in range(minexp, maxexp + 1):         xaxis.append(2**exp)     numflips in xaxis:         numheads = 0         n in range(numflips):             if random.random() < 0.5:                 numheads += 1         numtails = numflips - numheads         ratios.append(numheads/float(numtails))         diffs.append(abs(numheads - numtails))     pylab.title('difference between heads , tails')     pylab.xlabel('number of flips')     pylab.ylabel('abs(#heads - #tails)')     pylab.plot(xaxis, diffs)     pylab.figure()     pylab.title('heads/tails ratios')     pylab.xlabel('number of flips')     pylab.ylabel('#heads/#tails')     pylab.plot(xaxis, ratios)  random.seed(0) flipplot(4, 20) 

what need code running?

note: experience programming , python limited; i'm starting out.

you need use pylab.show() otherwise nothing come up.

see example here: http://matplotlib.org/examples/pylab_examples/simple_plot.html

(although should avoid using from pylab import *, way import fine.)

there cases in matplotlib not want show graph. example have designing graph on server using data collected automated process. server has no screen , accessed terminal, , therefore trying show graph result in error there no display variable set (there no screen display to).

in case normal save figure somewhere using pylab.savefig(), , maybe email or use ftp send somewhere can viewed.

because of matplotlib not implicitly show graph , must asked show it.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -