Sparse mesh on a surface plot with dense sampling

9 views (last 30 days)
Hi everyone!
At the surface plot example of Matlab, we have the following commands:
[X,Y,Z] = peaks(25);
CO(:,:,1) = zeros(25); % red
CO(:,:,2) = ones(25).*linspace(0.5,0.6,25); % green
CO(:,:,3) = ones(25).*linspace(0,1,25); % blue
surf(X,Y,Z,CO)
which produce the following figure:
If we increase the number of samples from 25 to 100, the mesh grid of the surface becomes denser:
Is there an easy way to have the smoothness of the secone one, with the grid of the first one? For example to show every N-th line (here, for example, 100/25 = 4, so every 4th line)?
Plotting the sparse mesh grid over a mesh-free surface won't help me, I want to be able to do this through the properties of the generated figure, as I want to be able to do this for figures produced by apps like the Curve Fitting app etc.
Thank you for your time!

Accepted Answer

Matt J
Matt J on 3 Nov 2022
Edited: Matt J on 3 Nov 2022
Plotting the sparse mesh grid over a mesh-free surface won't help me, I want to be able to do this through the properties of the generated figure, as I want to be able to do this for figures produced by apps like the Curve Fitting app etc.
That doesn't rule out overlaying 2 surface plots. All apps that I an think of allow you to export the results in code form, which you can then modify. You are never stuck with just a plot.
Otherwise, no, it's not possible. If you find the dense grid lines obtrusive, you could get rid of them, or make them more transparent:
[X,Y,Z] = peaks(100);
CO(:,:,1) = zeros(100); % red
CO(:,:,2) = ones(100).*linspace(0.5,0.6,100); % green
CO(:,:,3) = ones(100).*linspace(0,1,100); % blue
surf(X,Y,Z,CO,'EdgeAlpha',0.3)

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!