import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d import proj3d data = [ ["SAT0", 1346.496594546033, -6631.509574249269, -1784.401979591288], ["SAT1", 3986.6137971140965, -4309.794821125442, 3652.552861361319], ["SAT2", 6066.873731024742, 1768.4246674363346, -2645.6457201477174], ["SAT3", -531.4244577628424, -5725.907186159696, -3873.2462304175233], ["SAT4", -3029.294804348662, -6060.24715150741, -1163.1126511352572], ["SAT5", 4235.879179136093, -5048.655863634309, -1330.5861403372983], ["SAT6", -3213.176589077265, -4782.048496222451, -3740.7862955786086], ["SAT7", 176.0460873300058, 488.53751332601894, -6717.752685099294], ["SAT8", 286.49182959607276, 19.39475455789748, -6993.120858082854], ["SAT9", 6399.451382476649, -2113.9916687975474, -2002.7547869095122], ["SAT10", 3257.7488038015017, 1981.1452195906668, -5821.828870417848], ["SAT11", -581.1213836443779, 3374.6766339195256, 5964.093711437812], ["SAT12", 217.1789623719815, 178.85016316224656, -6843.305647372251], ["SAT13", 1176.6725366453472, -4957.9575328468, 4380.506198321206], ["SAT14", -1068.982383556387, 526.9728758308576, 6575.590264183411], ["SAT15", 1165.7614133253296, 584.8807748235947, 6545.811084796057], ["SAT16", -5993.097263023728, 2437.0166813209858, 2726.5808375640754], ["SAT17", -219.2118047031717, -105.032581318871, -6728.36026711676], ["SAT18", 3868.5717603149724, 4556.803440191685, -3214.801047688104], ["SAT19", 55.609142839530044, -1439.9935335382188, -6839.854023068437], ["Start", -2633.5917604717556, -5669.215907008842, -1230.3765435398993], ["End", -5854.876300459916, -190.38043902511365, -2504.759428517919] ] x = [a[1] for a in data] y = [a[2] for a in data] z = [a[3] for a in data] names = [a[0] for a in data] fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(x,y,z) plotlabels = [] for name,xi,yi,zi in zip(names,x,y,z): x2, y2, _ = proj3d.proj_transform(xi,yi,zi, ax.get_proj()) h = plt.annotate(name, xy = (x2,y2), xytext=(-20,20), textcoords='offset points', ha = 'right', va = 'bottom', bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5), arrowprops = dict(arrowstyle = '-', connectionstyle = 'arc3,rad=0')) plotlabels.append(h) def update_position(e): for h,xi,yi,zi in zip(plotlabels, x, y, z): x2, y2, _ = proj3d.proj_transform(xi,yi,zi, ax.get_proj()) h.xy = x2,y2 h.update_positions(fig.canvas.renderer) fig.canvas.draw() fig.canvas.mpl_connect('motion_notify_event', update_position) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') plt.show()