Finding the 2d canvas/figure position of a point in a 3d plotted axes [Matlab versions with HG2]

4 ビュー (過去 30 日間)
I am trying to annotate a 3D plot in MATLAB by projecting a 3D point onto the 2D canvas (or figure). Specifically, I need to determine the exact 2D position of a point that is displayed within a 3D axes in order to place an annotation (like text, arrows, etc.) in the correct spot on the figure.
The main challenge I am facing is that the conversion between the 3D data space and the 2D figure coordinates is not straightforward in MATLAB's Handle Graphics system (HG2), which was introduced after R2014b. Before 2014, under HG1, there was a code available here that converts 3D coordinates to normalized figure coordinates. However, this solution no longer works for MATLAB versions using HG2 (post-2014).
Is there a way to find the 2D canvas/figure position of a 3D point using MATLAB with HG2? I need a method that can handle newer versions of MATLAB (R2014b and later).
Any advice or code snippets to solve this problem would be greatly appreciated!

回答 (1 件)

Abhinav Aravindan
Abhinav Aravindan 2024 年 9 月 10 日
編集済み: Abhinav Aravindan 2024 年 9 月 10 日
I understand that you are trying to annotate a 3D plot in MATLAB and are encountering some issues. I assume you require the conversion between the 3D data space to 2D figure coordinates as an input to the “annotation” function for adding annotations to the 3D plot. Here are a few suggestions that might be helpful:
1. You may utilize the “quiver3” function to add arrows and the “text” function for adding text to your 3D plot as follows:
The vectors X, Y, and Z represent the location of the base of each arrow, and U, V, and W represent the directional components of each arrow.
quiver3(X,Y,Z,U,V,W)
To add a text at coordinate (x,y,z)
text(x,y,z,txt)
2. Alternatively, you may try out the functions in the following File Exchange submissions.
Reference:
I hope the above resources help in resolving your issue!

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by