plot in logarithmic scale
조회 수: 30 (최근 30일)
이전 댓글 표시
can someone tell me how in a 3d graph I can plot linearly the X and Y axis, while the Z axis (ZZ in this case) to plot it in logarithmic scale?
the command I use is contourf(XX,YY,ZZ,900,'linecolor','none').
thankss
댓글 수: 0
채택된 답변
Star Strider
2022년 1월 12일
The contourf function plots a plane, not a surface.
To plot logarithmic contours of the ‘Z’ matrix, it will be necessary to calculate the logarithm of the matrix.
Z = randn(10) % Create Matrix
figure
contourf(Z)
colormap(turbo(10))
colorbar
title('$Original\ Z$', 'Interpreter','latex')
figure
contourf(log(abs(Z))) % Logarithms Of The Absolute Values
colormap(turbo(10))
colorbar
title('$log(|Z|)$', 'Interpreter','latex')
Zs = Z;
Zs(Zs<=0) = NaN; % 'NaN' Values Do Not Plot, log(NaN)= NaN
figure
contourf(Zs)
colormap(turbo(10))
colorbar
title('$log(Z > 0)$', 'Interpreter','latex')
.
댓글 수: 2
Star Strider
2022년 1월 12일
I can probably make it work if I have your data and the relevant part of the code.
Using synthetic data —
x = 0:9;
y = 4:13;
z = randn(10);
figure
contourf(x, y, log(abs(z)))
colormap(turbo(10))
colorbar
So it definitely can work with linear ‘x’ and ‘y’ vectors (or matrices created from them using ndgrid or meshgrid).
.
추가 답변 (1개)
Simon Chan
2022년 1월 12일
I think you may need to use function contour3.
Then you can set the Z-axis scale to log by
set(gca,'ZScale','log')
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!