dewalla
dewalla

Reputation: 1327

How to add a "pointer" annotation to a 3-D plot in MATLAB?

I want to add a "Pointer" to a 3-D plot.
I want this "pointer" to point at a certain spot on a sphere that I have drawn.
This pointer does not have to have an arrowhead but would be nice if it did.

Thanks for any help!

Upvotes: 1

Views: 6779

Answers (3)

Amro
Amro

Reputation: 124563

Also make sure to check out the excellent ARROW submission on FEX by Erik Johnson (dates back to 2000 but updated in 2009).

screenshot http://www.mathworks.com/matlabcentral/fx_files/278/3/arrow_demo.png

Upvotes: 3

High Performance Mark
High Performance Mark

Reputation: 78316

And the easy way to add arrows and such like is to use the Plot Tools. You can activate the Plot Tools by clicking on the rightmost icon in the toolbar on the window containing the figure you have drawn. Once you've got the arrow as you want it, you could then generate the m-file from the graphic.

Upvotes: 2

zellus
zellus

Reputation: 9592

Plain copy from The MathWorks documentation. For further details have a look at this.

% Create a sphere and color it using a topographic colormap:
cla reset;
load topo;
[x y z] = sphere(45);
s = surface(x,y,z,'FaceColor','texturemap','CData',topo);
colormap(topomap1);
% Brighten the colormap for better annotation visibility:
brighten(.6)
% Create and arrange the camera and lighting for better visibility:
campos([2 13 10]);
camlight;
lighting gouraud;
axis off vis3d;
% Set the x- and y-coordinates of the textarrow object:
x = [0.7698 0.5851];
y = [0.3593 0.5492];
% Create the textarrow object: 
txtar =  annotation('textarrow',x,y,'String','We are here.','FontSize',14);

Upvotes: 3

Related Questions