1

Not sure why this simple plot won't show. simply shows an In[*] and won't finish loading the plot. Can't find any info on what the * means. Any help?

import numpy as np
import matplotlib.pyplot as plt


r = np.arange(1,11)
v2 = 1.0/r

font = {'family' : 'serif',
    'color'  : 'black',
    'weight' : 'normal',
    'size'   : 18,
    }
plt.xlabel('$V*$', fontdict = font)
plt.ylabel('$Radii$', fontdict = font)
plt.plot(r,v2,lw=2)
plt.show()
4
  • Are you importing the modules properly? Can you post how you are importing the libs? Commented Sep 10, 2015 at 5:28
  • 3
    Can't replicate the issue, this plots fine for me, try a different backend, e.g. %matplotlib inline Commented Sep 10, 2015 at 5:31
  • Edited to show the imported modules Commented Sep 10, 2015 at 5:48
  • So I added in %matplotlib inline and it's working now. This is my first time using matplotlib, really sorry I guess I didn't do enoug research on how to get it working. Thanks! I'm going to go look up what exactly that does now, so hopefully I wont make that mistake again Commented Sep 10, 2015 at 5:51

1 Answer 1

2

Setting the iPython notebook %matplotlib magic command here is what you need to display the plot.

Basically, that command tells the notebook which backend to use when plotting with matplotlib, and sets it to work interactively. You usually will want to set that at the top of your notebook.

There are several options. A common one is

%matplotlib inline

which displays the plots right there in the iPython notebook.

Other options will depend on your system, but can include:

‘gtk’, ‘gtk3’, ‘inline’, ‘nbagg’, ‘notebook’, ‘osx’, ‘qt’, ‘qt4’, ‘qt5’, ‘tk’, ‘wx’

If you just set:

%matplotlib

without a gui option, it will use the default backend on your system (defined in your .matplotlibrc file).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.