Для построения 2D-точек с помощью Matplotlib вы можете использовать различные методы. Вот некоторые часто используемые подходы:
Метод 1: использование точечной диаграммы
import matplotlib.pyplot as plt
# Define the coordinates of the points
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a scatter plot
plt.scatter(x, y)
# Add labels and title
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('2D Point Plot')
# Display the plot
plt.show()
Метод 2: использование функции построения графика
import matplotlib.pyplot as plt
# Define the coordinates of the points
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a line plot
plt.plot(x, y, 'o')
# Add labels and title
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('2D Point Plot')
# Display the plot
plt.show()
Метод 3: использование линейного графика со стилем маркера
import matplotlib.pyplot as plt
# Define the coordinates of the points
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a line plot with marker style
plt.plot(x, y, marker='o', linestyle='')
# Add labels and title
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('2D Point Plot')
# Display the plot
plt.show()
Метод 4. Использование линейного графика с отдельными точками
import matplotlib.pyplot as plt
# Define the coordinates of the points
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a line plot with individual points
plt.plot(x, y, '-o')
# Add labels and title
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('2D Point Plot')
# Display the plot
plt.show()
Метод 5. Использование точечной диаграммы с индивидуальным стилем и цветом маркера
import matplotlib.pyplot as plt
# Define the coordinates of the points
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a scatter plot with customized marker style and color
plt.scatter(x, y, marker='*', color='red')
# Add labels and title
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('2D Point Plot')
# Display the plot
plt.show()