Hi,
I want to add a point to this figure. Can you please tell me how to do that ?
the point that I want to add to my figure is: x=70.00; y= 0.30. Thanks for your time.

 採用された回答

Star Strider
Star Strider 2025 年 4 月 8 日
編集済み: Star Strider 2025 年 4 月 8 日

0 投票

Probably the easiest way —
figure
% surf(...)
% view(0,90)
hold on
plot3(70.00, 0.30, 1, 'sr', MarkerFaceColor='r')
hold off
view(0,90)
Ax = gca;
Ax.YScale='log';
You can also vary the MarkerSize and other properties.
Since you are plotting on a surface, it may be necessary to use the scatteredInterpolant function to put the point exactly on the surface, or just use the maximum value for the surface (apparently 1, according to the colorbar scale), as I did here.
EDIT — Added explanatory detail.
.

6 件のコメント

Adnan
Adnan 2025 年 4 月 8 日
Thanks for that , yet I got the point in a new figure. I want to have the point on my main figure not in a seperate figure. Please see the script that I used.
figure;
surf(t, fliplr(f), ST_normalized, EdgeColor='none')
ax = gca;
ax.YDir = 'normal';
ylabel('Frequency, Hz')
xlabel('Time (s)')
colorbar;
colormap(jet(256));
view(0,90)
axis('tight')
ax.YScale = 'log';
ax.YAxis.Exponent = 1;
hold on
plot(70.00, 0.30, 'sr', MarkerFaceColor='r')
hold off
Ax = gca;
Ax.YScale='log';
Star Strider
Star Strider 2025 年 4 月 8 日
編集済み: Star Strider 2025 年 4 月 8 日
It will be in the same figure, and on the same axes. (I would have plotted it with your matrix if I had your matrix to work with.)
Note my use of:
hold on
hold off
that will plot the point on the original axes.
See the documentation on the hold functiion for detaiils on what it does and how to use it.
EDIT — (8 Apr 2025 at 13:18)
Example —
[X,Y,Z] = peaks(50);
Y = Y-min(Y(:))+0.1;
figure
surf(X, Y, Z, EdgeColor='interp')
colormap(turbo)
colorbar
view(0,90)
hold on
plot3(1.00, 0.30, max(Z(:)), 'sr', MarkerFaceColor='r') % Changed ‘70.00’ To ‘1.00’
hold off
view(0,90)
Ax = gca;
Ax.YScale='log';
●
..
Adnan
Adnan 2025 年 4 月 8 日
thanks for that @Star Strider
Star Strider
Star Strider 2025 年 4 月 8 日
As always, my pleasure!
Image Analyst
Image Analyst 2025 年 4 月 8 日
@Adnan, there is also drawpoint and a set of other associated functions for other "draw" functions that you may want to check out, though I agree that plot() is certainly the easiest way.
Adnan
Adnan 2025 年 4 月 8 日
Thanks for that @Image Analyst

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索

製品

リリース

R2024b

タグ

質問済み:

2025 年 4 月 8 日

コメント済み:

2025 年 4 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by