Contour Plot when both x & y axis are in logscale

Can anyone help me to contour plot when both x & y axis are in logscale? Please see the figure.
I have coded like below but it didn't show logscale in both axis:
f=logspace(-3,0,100);
R0=logspace(-6,-2,100);
[X,Y]=meshgrid(f,R0);
%%%Main code body
....
.....
.....
Z=1+(gamma/(k*d^2))*(f.^2*delL+delR+2*R0.*X.*Gamma_func);
%%%%%%%
contour(X,Y,Z)

Respuestas (2)

x = linspace(0,2*pi);
y = linspace(0,4*pi);
[X,Y] = meshgrid(x,y);
Z = sin(X)+cos(Y);
% Plot using contour
figure;
contour(X,Y,Z);
% Use the 'set' command to graph in log scale
set(gca, 'XScale', 'log');
set(gca, 'YScale', 'log');
axis tight; % Adjust the axis limits
xlabel('X');
ylabel('Y');
Chunru
Chunru el 19 de Ag. de 2022
Editada: Chunru el 19 de Ag. de 2022
[x, y, z] = peaks;
x = x+4; y = y+4; z=z+8; % make it positive
figure
contourf(x, y, z);
colorbar
xlabel('x'); ylabel('y');
figure
%contour(log10(x), log10(y), z);
contourf(log10(x), log10(y), log10(z));
h2 = colorbar;
zt = h2.Ticks;
h2.TickLabels = "10^{"+string(zt')+"}";
% customize ticklabels
xt = xticks;
xticklabels("10^{"+string(xt')+"}");
yt = yticks;
yticklabels("10^{"+string(yt')+"}");
xlabel('x'); ylabel('y');

4 comentarios

Thank you for your response. Pls see my figure. I want log scaling in both X and Y axis.
Chunru
Chunru el 19 de Ag. de 2022
Editada: Chunru el 19 de Ag. de 2022
Yes. The plot has log scaling for both X and Y axes. Do you also want to have log-scale z-axis?
The code has been updated for log scale for x, y and z axes.
Thank you.But what you plotted is not representing the axis are in logarithm scale.
Chunru
Chunru el 19 de Ag. de 2022
What do you mean? They are indeed in log scale.

Iniciar sesión para comentar.

Categorías

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

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 19 de Ag. de 2022

Comentada:

AD
el 31 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by