We'll consider an elementary power function, namely the quadratic function $ f(x) = x^{2} $
Steps:
- import pylab and numpy
- set the range of x-values. Here, we'll go from -5 to +5, with a step of 0.01
- define the function y in terms of xVals (x-values)
- label the x and y axes
- give the graph a title. Here, we keep it simple with f(x) = x^2
- plot the graph. Here, xVals are the x-values, y are the y-values, and 'b' makes the curve blue
![]() | |
Enter the code directly into the iPython console |
![]() |
Our graph, nice and simple |
Tools >> Preferences >> iPython Console >> Graphics >> Graphics Backend, and set the backend to Automatic.
Next time, we'll plot some data points.
No comments:
Post a Comment