chatgpt/python-check-point.py

22 lines
466 B
Python

import matplotlib.pyplot as plt
import numpy as np
# Create some sample data
x = [1, 5]
y = [2, 10]
# Fit a line to the data using numpy
coefficients = np.polyfit(x, y, 1)
line = np.poly1d(coefficients)
# Check if the point (3, 6) is above or below the line
point = (3, 2)
if point[1] > line(point[0]):
print('The point is above the line.')
else:
print('The point is below the line.')
plt.plot(x, y)
plt.scatter(point[0], point[1], color='r')
plt.show()