Mo Houshmand
Mo Houshmand

Reputation: 145

Parabolic velocity profile in Python

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:

https://i.sstatic.net/28KpB.png

This plot is pointing upwards y-axis, but I want the plot to be like this:

https://i.sstatic.net/34AQi.png

but with y-axis = [-2, 2] and not [0, 5].

How could I do this?

Upvotes: 0

Views: 1145

Answers (1)

Holt
Holt

Reputation: 37626

You need to switch x and y:

h = 2
y = linspace(-2, 2, 101)
plot(h**2 - y**2, y)

Upvotes: 1

Related Questions