how to plot 2 colorbars from same set of data in contourf

3 vues (au cours des 30 derniers jours)
Jacqueline Mifsud
Jacqueline Mifsud le 4 Juin 2020
Réponse apportée : darova le 13 Juin 2020
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
Jacqueline Mifsud
Jacqueline Mifsud le 13 Juin 2020
can you explain a bit more how ?
darova
darova le 13 Juin 2020
Bad idea about surf and patch. BUt you can modify existing colorbar

Connectez-vous pour commenter.

Réponses (1)

darova
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])

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!

Translated by