plot in logarithmic scale
30 views (last 30 days)
Show older comments
ELISABETTA BILLOTTA
on 12 Jan 2022
Commented: Star Strider
on 12 Jan 2022
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 Comments
Accepted Answer
Star Strider
on 12 Jan 2022
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 Comments
Star Strider
on 12 Jan 2022
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).
.
More Answers (1)
Simon Chan
on 12 Jan 2022
I think you may need to use function contour3.
Then you can set the Z-axis scale to log by
set(gca,'ZScale','log')
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!