0

Here is a short code :

import numpy as np   
from scipy.stats import expon
import matplotlib.pyplot as plt

x = np.arange(0, 10, 0.001)
plt.plot(x, expon.pdf(x))

When I type that in the shell in using ipython, that didn't show up anything while it is supposed to plot the exponential distribution for x between 0 and 10. Could anyone be able to tell me what is the problem here?

I got that, but the plot did show up

In [16]: plt.plot(x, norm.pdf(x))
Out[16]: [<matplotlib.lines.Line2D at 0x7fbfe6bc2890>]

Thanks in advance!

P.S. Be aware that I am using Ubuntu 16.10 (Linux distribution).

  • @ImportanceOfBeingErnest ... the terminal –  Apr 09 '17 at 19:49
  • @ImportanceOfBeingErnest Just bash –  Apr 09 '17 at 19:51
  • Yes I could. If you install ipython and execute `ipython`, then we can enter import lib and using it normally. Btw, yes I use np (numpy here). You could see the edit of the question. –  Apr 09 '17 at 19:52

1 Answers1

0

It seems you are using IPython. Depending on in which environment you use it, you can create inline plots or plot to a window.

Ipython in Jupyther QtConsole allows to set the inline backend, %matplotlib inline.

enter image description here

In IPython without graphical support, you need to invoke a plotting window using plt.show()

enter image description here

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712