Contourf and colormap limits
Show older comments
Hi there!
Let's say I want to plot this:
contourf(peaks,16)
caxis([-2 2])
colorbar
Now I get:

But I want to show black contour lines only in the caxis limits AND also the color levels in the same limits, i.e. 16 color levels in [-2 2], not just 6 like in the picture.
Any ideas? Thanks
Accepted Answer
More Answers (1)
A nice automatic way you can set a similar contour increments and colorbar for two or more figures is:
num_levels = 32;
figure
tiledlayout(1,2, TileSpacing="compact")
nexttile
contourf(x, y, z, num_levels)
colorbar
col_range = clim;
nexttile
contourf(x, y, z, linspace(col_range(1), col_range(2), num_levels))
colorbar
Categories
Find more on Contour 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!


