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!