caxis equivalent for slice plot

4 views (last 30 days)
Nick K
Nick K on 30 Dec 2020
Commented: Ameer Hamza on 31 Dec 2020
I have a plot that uses the slice command.
Is there a way to rescale the colormap of the resulting slice as would usully be done throiugh caxis([lower upper])?

Accepted Answer

Ameer Hamza
Ameer Hamza on 30 Dec 2020
Edited: Ameer Hamza on 30 Dec 2020
caxis() also works for slice(). See the difference between two figures
[X,Y,Z] = meshgrid(-2:.2:2);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = [-1.2,0.8,2];
yslice = [];
zslice = 0;
caxis([-2 2])
Nick K
Nick K on 30 Dec 2020
Ahh great, thank you, you confirmed my suspicion!
I was encounering an error message when trying to do this, hence my question. My plot is a combination of several isosurfaces and a background slice. I think the error was due to Matlab believing I was enforcing the colorbar onto the iso-surface part of my plot, as opposed to the slice. By simply plotting the slice first, it was fixed.
Thank you, sir!
Ameer Hamza
Ameer Hamza on 31 Dec 2020
I am glad to be of help!

Sign in to comment.

More Answers (0)


Find more on Colormaps 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!