1

I am very new to Python. Just installed it yesterday on Ubuntu 15.04. Now I am trying to output a parabola from the terminal. As far I understand I can not output any drawing on terminal so how can I see the graph?

I did : sudo apt-get install python-numpy python-scipy python-matplotlib

my code is

import matplotlib.pyplot as plt
import numpy as np

# create 1000 equally spaced points between -10 and 10
x = np.linspace(-10, 10, 1000)

# calculate the y value for each element of the x vector
y = x**2 + 2*x + 2  

fig, ax = plt.subplots()
ax.plot(x, y)

it does not show error when i do python parabola.py but no output :(

1 Answer 1

6

You need to add plt.show() at the end of the code, to display the parabola.

http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show

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.