Monday, June 20, 2022

Plotting multiple points from a list using matplotlib

Логика кода ниже вполне прозрачна, расщепление каждого элемента в списке точек на х,y,z компоненты

 (.env) boris@boris-All-Series:~/VOTING$ cat PlotingDotSet.py

points_list = ['2.449,14.651,-2.992,', '6.833,13.875,-3.021,', '8.133,17.431,-5.150,', '3.039,13.724,-3.999,', '16.835,9.456,-2.031,', '15.801,25.161,-7.463,', '14.668,23.056,-4.382,', '22.378,20.268,-3.457,', '21.121,17.041,-6.353,', '19.472,13.555,-3.192,', '22.498,20.115,-2.436,']

import numpy as np

import matplotlib.pyplot as plt

x = [float(point.split(',')[0]) for point in points_list]

y = [float(point.split(',')[1]) for point in points_list]

z = [float(point.split(',')[2]) for point in points_list]

fig = plt.figure()

ax = plt.axes(projection='3d')

ax.scatter(x, y, z)

plt.show()

































No comments:

Post a Comment