How to plot the labels of contours

조회 수: 1 (최근 30일)
Ivan Mich
Ivan Mich 2022년 5월 13일
편집: Ivan Mich 2022년 5월 16일
hello,
I would to ask about contours plot in matlab. I am using thefollowing commands in order to plot contours.
t=importdata('input.txt');
x=t(:,1);
y=t(:,2);
z=t(:,5);
[xi, yi] = meshgrid(...
linspace(min(x),max(x)),...
linspace(min(y),max(y)));
zi = griddata(x,y,z, xi,yi,'natural');
figure(1)
contourf(xi,yi,zi,15,'LineStyle','none')
set(gca,'ColorScale','log')
colormap(flipud(hot(50)))
The question is how could I plot the labels of the contours in my plot?
could you please help me?

채택된 답변

CHIRANJIT DAS
CHIRANJIT DAS 2022년 5월 13일
편집: CHIRANJIT DAS 2022년 5월 13일
Just use contour and label them
figure(1)
contourf(xi,yi,zi,15,'LineStyle','none')
hold on
[C,h] = contour(xi,yi,zi,15);
dx=20;
% change dx to increase fontsize
clabel(C,h,'FontSize',dx,'Color','red')
set(gca,'ColorScale','log')
colormap(flipud(hot(50)))
You can also define your contour labels. Hope it works
  댓글 수: 3
CHIRANJIT DAS
CHIRANJIT DAS 2022년 5월 13일
@Ivan Mich see the edited answer.
Ivan Mich
Ivan Mich 2022년 5월 15일
편집: Ivan Mich 2022년 5월 16일
Excuse me, I have a question. I would like to have the same bins and color classification in contourmap and in colorbar. But the point is that I can not make it, despite the search I did.
(for example I would like to have 4 color bins in contour map and in colorbar too)
Could you please help me?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by