Note that there are some explanatory texts on larger screens.

plurals
  1. POLabel 3Dplot points + update
    text
    copied!<p>I'm quite new with python and matplotlib and this website helped me a lot. but I couldn't find a complete answer about this subject.</p> <p>I would like to annotate the point of a 3d plot using matplotlib, so after some research I found this peace of code : <a href="https://stackoverflow.com/questions/10374930/matplotlib-annotating-a-3d-scatter-plot">Matplotlib: Annotating a 3D scatter plot</a></p> <pre><code> import pylab from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d import proj3d fig = pylab.figure() ax = fig.add_subplot(111, projection = '3d') x = y = z = [1, 2, 3] sc = ax.scatter(x,y,z) # now try to get the display coordinates of the first point x2, y2, _ = proj3d.proj_transform(1,1,1, ax.get_proj()) label = pylab.annotate( "this", 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 = '-&gt;', connectionstyle = 'arc3,rad=0')) def update_position(e): x2, y2, _ = proj3d.proj_transform(1,1,1, ax.get_proj()) label.xy = x2,y2 label.update_positions(fig.canvas.renderer) fig.canvas.draw() fig.canvas.mpl_connect('button_release_event', update_position) pylab.show() </code></pre> <p>but the thing is, I manage to update only the last label with this code, I tried to do some loop in the update_position(e) function. But I'm certainly missing something. So far I used the Axes3D.text(x, y, z, s, zdir) function, but it's not looking really good.</p> <p>thanks !</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload