How to plot the labels of contours

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?

 Respuesta aceptada

CHIRANJIT DAS
CHIRANJIT DAS el 13 de Mayo de 2022
Editada: CHIRANJIT DAS el 13 de Mayo de 2022
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 comentarios

Ivan Mich
Ivan Mich el 13 de Mayo de 2022
ok thank you very much.
Is there a way to change the fonts of these labels??
CHIRANJIT DAS
CHIRANJIT DAS el 13 de Mayo de 2022
@Ivan Mich see the edited answer.
Ivan Mich
Ivan Mich el 15 de Mayo de 2022
Editada: Ivan Mich el 16 de Mayo de 2022
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?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Mayo de 2022

Editada:

el 16 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by