How to add a 'marker' and a 'textbox' for a given x,y,z in a surface?
3 views (last 30 days)
Show older comments
Hi guys,
A relatively simple question. I want to graph the below surface. But with it, I want to highlight just ONE point based on a given x,y (in this case f1, f2) and have a related textbox appear which gives me the coordinates. For example, like this:
*X-Value: 4 Y-value:5 Z-value: 2
I tried data cursor, but it requires that you click on it and it doesn't become PART OF the surface.
Thank you. Here is the test surface:
x = [0:20];
y = [0:20];
f1 = 1;
f2 = 2;
constant = 3;
% Calculate data
TestFormula = @(x,y)(x + y.*constant);
[X,Y] = meshgrid(x,y);
Z1 = TestFormula(X,Y);
Z2 = TestFormula(f1,f2);
% Create frequency plot in proper axes
s1 = surf(X,Y,Z1);
xlabel('X', 'fontweight', 'bold')
ylabel('Y', 'fontweight', 'bold')
view (135,15);
yh = get(gca,'YLabel'); % Handle of the y label
set(yh, 'Units', 'Normalized')
pos = get(yh, 'Position');
set(yh, 'Position',pos.*[0.85,0.6,1],'Rotation',-10.9)
xh = get(gca,'XLabel'); % Handle of the x label
set(xh, 'Units', 'Normalized')
pos = get(xh, 'Position');
set(xh, 'Position',pos.*[1,1,1],'Rotation',11.1)
zlabel('Z', 'fontweight', 'bold')
zh = get(gca,'ZLabel'); % Handle of the z label
set(zh, 'Units', 'Normalized')
pos = get(zh, 'Position');
set(zh, 'Position',pos.*[1.5,1,0],'Rotation',90)
axis tight
camlight
lighting phong
shading interp
set(s1,'FaceColor',[0 0.63 0.91], 'edgecolor',[0 0 0.4],'meshstyle','both','linewidth',.15);
grid on
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!