[python-uk] Matplotlib show() doesn't display on OS X

Simon Walker s.r.walker101 at googlemail.com
Tue Apr 26 05:38:17 EDT 2016


Otherwise, it might be worth playing around with your render backend.

In your code, you can add the following snipped *before* any other imports of matplotlib:

    import matplotlib
    matplotlib.use('TkAgg')
    import matplotlib.pyplot as plt

Other options are: Qt4Agg, MacOSX

It's possible it's choosing the "Agg" renderer which is non-interactive.

If another backend works (e.g. I use TkAgg myself) then you can add it to the file ~/.matplotlib/matplotlibrc as:

    backend : TkAgg

Simon

> On 25 Apr 2016, at 19:55, Pepper R. <ryan.pepper at soton.ac.uk> wrote:
> 
> Are you sure it's not gone behind your other windows? This is what seems to happen by default on OS X with matplotlib.
> 
> R
> ________________________________________
> From: python-uk [python-uk-bounces+rp20g15=soton.ac.uk at python.org] on behalf of gvim [gvimrc at gmail.com]
> Sent: 25 April 2016 19:28
> To: UK Python Users
> Subject: [python-uk] Matplotlib show() doesn't display on OS X
> 
> I ran this simple script taken from a book:
> 
> #!/usr/bin/env python3
> 
> import matplotlib.pyplot as plt
> 
> squares = [1, 4, 9, 16, 25]
> plt.plot(squares)
> plt.show()
> 
> 
> ... but although the script runs without error it doesn't display
> anything, doesn't terminate and is unresponsive to either Ctrl+C or Ctrl+D.
> 
> gvim
> 
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> https://mail.python.org/mailman/listinfo/python-uk
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> https://mail.python.org/mailman/listinfo/python-uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/python-uk/attachments/20160426/5bd71c86/attachment.sig>


More information about the python-uk mailing list