How can I lock the colorbar when adding new contour plots?

2 views (last 30 days)
I am trying to plot multiple matrices using the 'contour' function.  I want the colorbar to be fixed after plotting the first matrix.  How can I do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Oct 2017
In order to lock the color range after plotting the first matrix, you can use the 'caxis' function.  Execute the following two lines of code after the first plot is made.
C=caxis;
caxis([C(1),C(2)])
The first line of code gets the current limits of the color axis.  The second line of code explicitly sets the limits of the color axis.  Explicitly setting the limits of the color axis should prevent MATLAB from automatically choosing limits on subsequent plots.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2015b

Community Treasure Hunt

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

Start Hunting!