plotting of functions in python
Title
Question
How do we plot parabola, hyperbola and an ellipse?
Python Using-the-plot-command-interactively 09-10 min 0-10 sec
Answers:
You will plot them similar to how you will plot the sin plot. If you remember in sin plot you mentioned the equation that you desired in the plot function.
For parabola, hyperbola and ellipses you will similarly specify the relevant functions along with the x value in the plot functions.
This could be a good exercise to see if you have understood how the plot function working.
You can plot parabola using its equation, as follows
Step 1 : import plot library
Import matplotlib
Step 2: Create Data range i.e. you want 20 points starting from -50 to +50
x=linespace(-50,50,20)
Step 3: lets say parabola equation is y=x**2, It will store square value of each x`s point into y
y=x**2
Step 4: Now, we have X and Y both, So, first initiate plot library than plot
%pylab
plot(x,y)
Login to add comment