[AstroPy] AstroPy Digest, Vol 155, Issue 14
Gordon Dennis
gordon.b.dennis at gmail.com
Tue Aug 27 15:22:25 EDT 2019
Hi everyone
A couple of people suggested the usual plt.show()after the third line, but
that doesn't change anything I'm afraid - the histogram still doesn't work
as the example shows.
Anybody any other suggestions please?.
Best regards
Gordon
-----Original Message-----
From: AstroPy [mailto:astropy-bounces+gordon.b.dennis=gmail.com at python.org]
On Behalf Of astropy-request at python.org
Sent: Tuesday, August 27, 2019 15:11
To: astropy at python.org
Subject: AstroPy Digest, Vol 155, Issue 14
Send AstroPy mailing list submissions to
<mailto:astropy at python.org> astropy at python.org
To subscribe or unsubscribe via the World Wide Web, visit
<https://mail.python.org/mailman/listinfo/astropy>
https://mail.python.org/mailman/listinfo/astropy
or, via email, send a message with subject or body 'help' to
<mailto:astropy-request at python.org>
astropy-request at python.org
You can reach the person managing the list at
<mailto:astropy-owner at python.org> astropy-owner at python.org
When replying, please edit your Subject line so it is more specific than
"Re: Contents of AstroPy digest..."
Today's Topics:
1. Re: Histogram problem in astropy tutorial (Lingyi Hu)
2. Re: Histogram problem in astropy tutorial (David Stansby)
----------------------------------------------------------------------
Message: 1
Date: Tue, 27 Aug 2019 21:55:36 +0800
From: Lingyi Hu <hulingyi1995 at yahoo.com.sg>
To: Astronomical Python mailing list <astropy at python.org>
Subject: Re: [AstroPy] Histogram problem in astropy tutorial
Message-ID:
<CAApfPRxK4Mke2HaYmsLHWPtVL4prtWK2ekWNbS_J1NOGfQbCww at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Gordon,
I believe you can do a normal plt.show() at the end of plotting to show the
graph. Don't think you need the exec(%matplotlib inline) if you are not in
ipython. I don't use Spyder but apparently there are some settings you can
set in Spyder to make it work like a IPython notebook:
<https://stackoverflow.com/questions/23585126/how-do-i-get-interactive-plots
-again-in-spyder-ipython-matplotlib>
https://stackoverflow.com/questions/23585126/how-do-i-get-interactive-plots-
again-in-spyder-ipython-matplotlib
Lingyi
On Tue, Aug 27, 2019 at 8:13 PM Gordon Dennis <
<mailto:gordon.b.dennis at gmail.com> gordon.b.dennis at gmail.com>
wrote:
> Hi everybody
>
> I'm having some difficulty with the example 'Galaxy mass' in the
> tutorial at
> <http://learn.astropy.org/rst-tutorials/quantities.html?highlight=filte>
http://learn.astropy.org/rst-tutorials/quantities.html?highlight=filte
> rtutorials
>
> These lines are to setup matplotlib:
>
> import matplotlib.pyplot as plt
>
> %matplotlib inline
>
> Spyder will not accept the second (i.e. %matplotlib inline) because,
> according to a Stack Overflow answer 'Line magics are only supported
> by the IPython command line. They cannot be used inside a script,
> because %something is not correct Python syntax'.
>
> Suggestion is to use
>
> exec(%matplotlib inline)
>
> This is accepted by the Python interpreter but doesn't work, i.e. the
> subsequent code
>
> plt.figure()
>
> plt.hist(v, bins='auto', histtype="step")
>
> plt.ylabel("N")
>
> ? does not produce the histogram expected. The variable v is
> calculated earlier in the code.
>
>
>
> All the rest of the code works exactly as expected. I've added input
> statements to vary Reff and vmean in order to observe the effect of
> varying these parameters and the results from the code check out
> against results using a calculator.
>
> I?m using Spyder 3 on Windows 10, fully patched.
>
> Does anyone know of a way around this histogram problem?
>
> Best regards
>
> Gordon Dennis
>
>
>
>
>
> +44(0)1934 838096 / +44(0)7774628110 / Skype: gordon.dennis
>
> Sent from my Analytical Engine
>
> [image: Description: analyticalEngine]
>
>
> _______________________________________________
> AstroPy mailing list
> <mailto:AstroPy at python.org> AstroPy at python.org
> <https://mail.python.org/mailman/listinfo/astropy>
https://mail.python.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
<http://mail.python.org/pipermail/astropy/attachments/20190827/32bd9a09/atta
chment-0001.html>
http://mail.python.org/pipermail/astropy/attachments/20190827/32bd9a09/attac
hment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 3301 bytes
Desc: not available
URL: <
<http://mail.python.org/pipermail/astropy/attachments/20190827/32bd9a09/atta
chment-0001.jpg>
http://mail.python.org/pipermail/astropy/attachments/20190827/32bd9a09/attac
hment-0001.jpg>
------------------------------
Message: 2
Date: Tue, 27 Aug 2019 15:10:28 +0100
From: David Stansby <dstansby at gmail.com>
To: Astronomical Python mailing list <astropy at python.org>
Subject: Re: [AstroPy] Histogram problem in astropy tutorial
Message-ID:
<CAGm9cHCnAc0hvrBLr-3OAxri7wvRzUo5ZfhzwVwL3wukf3tjeg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Gordon,
If you're using Matplotlib in a normal python session then you don't need
the '%matplotlib inline' command, but you will need to append 'plt.show()`
to the end of your script to make the figure show up.
Cheers,
David
On Tue, 27 Aug 2019 at 13:13, Gordon Dennis <
<mailto:gordon.b.dennis at gmail.com> gordon.b.dennis at gmail.com>
wrote:
> Hi everybody
>
> I'm having some difficulty with the example 'Galaxy mass' in the
> tutorial at
> <http://learn.astropy.org/rst-tutorials/quantities.html?highlight=filte>
http://learn.astropy.org/rst-tutorials/quantities.html?highlight=filte
> rtutorials
>
> These lines are to setup matplotlib:
>
> import matplotlib.pyplot as plt
>
> %matplotlib inline
>
> Spyder will not accept the second (i.e. %matplotlib inline) because,
> according to a Stack Overflow answer 'Line magics are only supported
> by the IPython command line. They cannot be used inside a script,
> because %something is not correct Python syntax'.
>
> Suggestion is to use
>
> exec(%matplotlib inline)
>
> This is accepted by the Python interpreter but doesn't work, i.e. the
> subsequent code
>
> plt.figure()
>
> plt.hist(v, bins='auto', histtype="step")
>
> plt.ylabel("N")
>
> ? does not produce the histogram expected. The variable v is
> calculated earlier in the code.
>
>
>
> All the rest of the code works exactly as expected. I've added input
> statements to vary Reff and vmean in order to observe the effect of
> varying these parameters and the results from the code check out
> against results using a calculator.
>
> I?m using Spyder 3 on Windows 10, fully patched.
>
> Does anyone know of a way around this histogram problem?
>
> Best regards
>
> Gordon Dennis
>
>
>
>
>
> +44(0)1934 838096 / +44(0)7774628110 / Skype: gordon.dennis
>
> Sent from my Analytical Engine
>
> [image: Description: analyticalEngine]
>
>
> _______________________________________________
> AstroPy mailing list
> <mailto:AstroPy at python.org> AstroPy at python.org
> <https://mail.python.org/mailman/listinfo/astropy>
https://mail.python.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
<http://mail.python.org/pipermail/astropy/attachments/20190827/c84c82ba/atta
chment.html>
http://mail.python.org/pipermail/astropy/attachments/20190827/c84c82ba/attac
hment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 3301 bytes
Desc: not available
URL: <
<http://mail.python.org/pipermail/astropy/attachments/20190827/c84c82ba/atta
chment.jpg>
http://mail.python.org/pipermail/astropy/attachments/20190827/c84c82ba/attac
hment.jpg>
------------------------------
Subject: Digest Footer
_______________________________________________
AstroPy mailing list
<mailto:AstroPy at python.org> AstroPy at python.org
<https://mail.python.org/mailman/listinfo/astropy>
https://mail.python.org/mailman/listinfo/astropy
------------------------------
End of AstroPy Digest, Vol 155, Issue 14
****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20190827/79a95d6e/attachment-0001.html>
More information about the AstroPy
mailing list