필터 지우기
필터 지우기

Contour Plot when both x & y axis are in logscale

조회 수: 66 (최근 30일)
Md Jahid Hasan Sagor
Md Jahid Hasan Sagor 2022년 8월 19일
댓글: AD 2023년 7월 31일
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)

답변 (2개)

Chunru
Chunru 2022년 8월 19일
편집: Chunru 2022년 8월 19일
[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
Md Jahid Hasan Sagor
Md Jahid Hasan Sagor 2022년 8월 19일
Thank you.But what you plotted is not representing the axis are in logarithm scale.
Chunru
Chunru 2022년 8월 19일
What do you mean? They are indeed in log scale.

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


Alexis Carranza Hidalgo
Alexis Carranza Hidalgo 2023년 7월 27일
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');
  댓글 수: 1
AD
AD 2023년 7월 31일
What should we do to set scale to millimeters?

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

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by