how to plot 2 colorbars from same set of data in contourf
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a contourf plot using a single set of data consisting of both positive and negative values.
I would like to plot two separate colorbars to easily distinguish between the positive and negative values (I assume this would require some conditional statement). I would like to have the 0 values of data in white, negative values in blue scale and positive values in red scale. Basically, similar to that shown in the figure.
Any ideas on how this can be done? I've looked through the forum but I can't seem to find something related to two color bars from the same set of data.

3 commentaires
Réponses (1)
darova
le 13 Juin 2020
- Create one more colorbar using copyobj
- Modify colorbars using set function
clc,clear
clf
[x,y,z] = peaks(50);
surf(x,y,z)
h = colorbar('location','north');
h1 = copyobj(h,gcf);
set(h,'position',[0.05 0.85 0.4 0.05])
set(h,'xlim',[2 5])
set(h1,'position',[0.55 0.85 0.4 0.05])
set(h1,'xlim',[-5 -2])

0 commentaires
Voir également
Catégories
En savoir plus sur Contour Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!