Reputation: 145
I am trying to plot a parabolic velocity profile such that the parabola is pointing in the positive x-direction.
from scitools.std import *
def v(y):
return h**2 - y**2
h = 2
x = linspace(0, 5, 101)
y = linspace(-2, 2, 101)
v = v(y)
plot(x, v)
I get the following:
This plot is pointing upwards y-axis, but I want the plot to be like this:
but with y-axis = [-2, 2]
and not [0, 5]
.
How could I do this?
Upvotes: 0
Views: 1145
Reputation: 37626
You need to switch x
and y
:
h = 2
y = linspace(-2, 2, 101)
plot(h**2 - y**2, y)
Upvotes: 1