Oswald
Oswald

Reputation: 3

searching for min(y) with the corresponding x (x and y are arrays)

`

import numpy as np

import matplotlib.pyplot as plt

x = np.array([3900.06,3900.16,3900.26])

y = np.array([0.311254,0.588623,0.724301])

if min(y):

print(x[min(y)])`

maybe someone can help me with the following problem: I'm searching for the x point where the point y is at minimum. enter image description here

Thanks, for any kind of help :)

Upvotes: 0

Views: 49

Answers (1)

Thomas Howard
Thomas Howard

Reputation: 61

Without testing whether or not y has a min (not sure if this is a requirement for the application without more source), using np.argmin():

import numpy as np

x = np.array([3900.06, 3900.16, 3900.26])
y = np.array([0.311254, 0.588623, 0.724301])

print(x[np.argmin(y)])

Upvotes: 1

Related Questions