1

I saw this post and added a print label.get_position(). It looks like this command returns the 2D-coordinates of the label, let's call it (u,v)-coordinates as marked green in the picture below. Now my question: Is there a way to get these (u,v)-coordinates of a certain 3D-point? How?

Edit: For example: I have a 3D-point with the (x,y,z)-coordinates (1,1,1). I want matplotlib to return me the (u,v)-coordinates of this point when I rotate the view around. In my example: In the first case, matplotlib should return me (4,3), in the second case (6,4). Hope this is clear enough now =)

enter image description here

Community
  • 1
  • 1
Munchkin
  • 4,528
  • 7
  • 45
  • 93
  • I don't understand your question. matplotlib only knows about 2D, anything 3D is done via projection to 2D. As near as I can tell, the question you link to answers any way I can find to interpret your question. – tacaswell Jul 10 '13 at 18:49
  • I edited my question. Hope you can understand it now :-) – Munchkin Jul 10 '13 at 19:00
  • That is exactly what the code in the question you linked to does. – tacaswell Jul 10 '13 at 19:05
  • Thank you for your comments, but I think you missunderstand me. If you add these two lines in the code i linked to: `print (x2,y2) print label.get_position()` you'll get two completey different values, which behave different when you rotate around. The value I get from `print label.get_position()` is exactly what I want, but that was just an example: I **don't** want to use **labels**, only work with my **points**, so I need a kind of `(1,1,1).get_position()`. Or is there something in the linked code I don't understand? – Munchkin Jul 10 '13 at 19:12
  • I would suggest reading the code in that answer carefully and make sure you understand what every line is doing, not just copy and pasting. – tacaswell Jul 10 '13 at 19:24
  • possible duplicate of [Matplotlib: Annotating a 3D scatter plot](http://stackoverflow.com/questions/10374930/matplotlib-annotating-a-3d-scatter-plot) – tacaswell Jul 10 '13 at 19:25

1 Answers1

1

Following the linked example, you use

x2, y2, _ = proj3d.proj_transform(x1,y1,z1, ax.get_proj())

To get the projection of 3D -> 2D.

Community
  • 1
  • 1
tacaswell
  • 84,579
  • 22
  • 210
  • 199
  • Oh damn, I always recognized (x2, y2) as (zero, zero) because I compared it with the values from `.get_position()`. But now I see it's the values I wanted. Thank you and I apologize =/ – Munchkin Jul 10 '13 at 20:34
  • @Munchkin No worries, glad you see it now. – tacaswell Jul 10 '13 at 20:44