How to add specified text to coordinates of points in "contour"?

3 ビュー (過去 30 日間)
Ravindu Lokuliyana
Ravindu Lokuliyana 2021 年 3 月 8 日
Hi there,
I need to represent the specified points which I name as P1,P2...P25 for the coordinates of contour plot.
The attached figure further demostrates the requirement.
Can anyone help me to solve this issue?
Thank you.

採用された回答

Mehmed Saad
Mehmed Saad 2021 年 3 月 8 日
Here is a sample code
I hate putting comments in code so try to understand it.
[X,Y,Z] = peaks;
contour(X,Y,Z,20)
hold on
xl = xlim;yl = ylim;
no_of_points_x = 5;
no_of_points_y = 5;
locX = reshape(repmat(linspace(xl(1),xl(2),no_of_points_x),no_of_points_y,1).',no_of_points_x*no_of_points_y,[]);
locY = reshape(repmat(linspace(yl(1),yl(2),no_of_points_y),no_of_points_x,1),no_of_points_x*no_of_points_y,[]);
plot(locX,locY,'.','MarkerSize',80,'MarkerFaceColor',[0 0.4470 0.4470])
text(locX,locY,strcat('P',string(1:no_of_points_x*no_of_points_y)),'HorizontalAlignment','center','Color','y')
set(gca,'YDir','reverse')
  1 件のコメント
Ravindu Lokuliyana
Ravindu Lokuliyana 2021 年 3 月 8 日
Thank you very much!!! This works perfect.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by