![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/542321/image.png)
How to add specified text to coordinates of points in "contour"?
조회 수: 3 (최근 30일)
이전 댓글 표시
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.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/542251/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/542251/image.jpeg)
댓글 수: 0
채택된 답변
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/542321/image.png)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!