Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100463
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Robert Kern <robert.kern@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Question about figure plot |
| Date | Tue, 15 Dec 2015 15:22:14 +0000 |
| Lines | 63 |
| Message-ID | <mailman.24.1450192941.22044.python-list@python.org> (permalink) |
| References | <ba4b4615-2739-49b3-9bb3-eafc527ddebc@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de X25i7cJ/MYSqb18snTMuZwQflds1BmT+7GledHIx4Rwg== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'defaults': 0.05; 'subject:Question': 0.05; 'api': 0.09; 'pyplot': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'script,': 0.09; 'subject:plot': 0.09; 'underlying': 0.09; 'assume': 0.11; 'def': 0.13; 'alpha': 0.15; '(note:': 0.16; 'kern': 0.16; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'url:faq': 0.16; 'wrote:': 0.16; 'figures': 0.18; 'windows': 0.20; 'skip:v 30': 0.20; 'interpret': 0.22; 'code,': 0.23; 'import': 0.24; 'examples': 0.24; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'figure': 0.27; 'right.': 0.27; 'function': 0.28; 'raise': 0.29; 'run': 0.33; 'attempt': 0.35; 'robert': 0.35; 'skip:p 30': 0.35; 'there': 0.36; 'url:org': 0.36; 'lines': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; 'no,': 0.38; 'skip:p 20': 0.38; 'hi,': 0.38; 'means': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'skip:n 10': 0.62; 'different': 0.63; 'our': 0.64; 'world': 0.64; 'believe': 0.66; 'here': 0.66; 'url:index': 0.67; 'eco': 0.84; 'modes:': 0.84; 'terrible': 0.84; 'choice.': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | uk.enthought.com |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
| In-Reply-To | <ba4b4615-2739-49b3-9bb3-eafc527ddebc@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:100463 |
Show key headers only | View raw
On 2015-12-15 02:43, Robert wrote:
> Hi,
>
> When I run the following code, there is no figure shown in the end.
>
>
> //////////
> import pymc
> import numpy as np
>
> n = 5*np.ones(4,dtype=int)
> x = np.array([-.86,-.3,-.05,.73])
>
> alpha = pymc.Normal('alpha',mu=0,tau=.01)
> beta = pymc.Normal('beta',mu=0,tau=.01)
>
> @pymc.deterministic
> def theta(a=alpha, b=beta):
> """theta = logit^{-1}(a+b)"""
> return pymc.invlogit(a+b*x)
>
> d = pymc.Binomial('d', n=n, p=theta, value=np.array([0.,1.,3.,5.]),\
> observed=True)
> ....
> import pymc
> import mymodel
>
> S = pymc.MCMC(mymodel, db='pickle')
> S.sample(iter=10000, burn=5000, thin=2)
> pymc.Matplot.plot(S)
>
>
>
> I find that the figures are shown after these two lines by myself:
> *************
> import matplotlib.pyplot as plt
> plt.show()
>
> I have searched around and have not found some explanation about it.
> The plot function here is different from Matlab's. Is there better ways than
> my last two lines? (I am not confident whether my last two lines is the
> only choice.
No, that's right. pymc.Matplot.plot() uses matplotlib's pyplot API underneath.
pyplot can run in two different modes: interactive and non-interactive. When
used in a standalone script, like I assume here, it defaults to non-interactive.
That means that it will not raise any plot windows until you call plt.show().
http://matplotlib.org/faq/usage_faq.html#what-is-interactive-mode
See any of the examples here (note: "pylab" is the essentially the same as
"pyplot" for these purposes):
http://matplotlib.org/examples/pylab_examples/index.html
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Question about figure plot Robert <rxjwg98@gmail.com> - 2015-12-14 18:43 -0800 Re: Question about figure plot Robert Kern <robert.kern@gmail.com> - 2015-12-15 15:22 +0000
csiph-web