# Two contourplots in one figure, data changed

3 Ansichten (letzte 30 Tage)
loes visser am 21 Dez. 2016
Bearbeitet: KSSV am 22 Dez. 2016
Hi!
I would like to show two different sets of data in contourplots in the same figure. I already tried some stuff. I made the two seperate plots;  I like to plot the red figure with contourm over the blue figure.
% make variabels mean_SkinTemp & S123_OmgTempIbutton same length as S123_CloValue etc
Bb = interp1( S123_SkinDateTime, mean_SkinTemp, S123_ComfortDateTime,'nearest');
Bc = interp1( S123_PhysDateTime, S123_OmgTempIbutton, S123_ComfortDateTime,'nearest');
% count how many measuring points are in each 1-by-1 cell in graph
stepsize = 1;
Ta1 = [10:stepsize:35];
Ts1 = [25:stepsize:42];
Z1 = zeros(length(Ts1),length(Ta1));
CLO = Z1;
ACT = Z1;
SENS = Z1-4;
COMF = Z1-4;
for row = 1: length(Ts)
for col = 1: length(Ta)
index_Ta_1 = find( Bc >= (Ta1(col)-(stepsize/2) ) );
index_Ta_2 = find( Bc < (Ta1(col)+(stepsize/2) ) );
index_Ta = intersect( index_Ta_1, index_Ta_2 );
index_Ts_1 = find( Bb >= (Ts1(row)-(stepsize/2) ) );
index_Ts_2 = find( Bb < (Ts1(row)+(stepsize/2) ) );
index_Ts = intersect( index_Ts_1, index_Ts_2 );
index_totaal = intersect( index_Ts, index_Ta);
Z1(row,col)= length(index_totaal);
if( ~isempty(index_totaal))
CLO(row,col)= median(S123_CloValue(index_totaal));
ACT(row,col)= median(S123_ActivityNu(index_totaal));
SENS(row,col)= median(S123_Sensation(index_totaal));
COMF(row,col)= median(S123_Comfort(index_totaal));
end
end
end
Z1 = Z1/(sum(sum(Z1)));
figure(12)
%create axes for pcolor and store handle
hAxesP = axes;
%set colormap for pcolor axes
colormap(hAxesP,flipud(gray));
pcolorPlot = pcolor(Ta1,Ts1,Z1);
set(pcolorPlot,'FaceColor','interp','EdgeColor','interp');
%create color bar and set range for color
cbP = colorbar(hAxesP,'Location','west');
caxis(hAxesP,[min(min(Z1)) max(max(Z1))]);
%create axes for the countourm axes
hAxesCM = axes;
%set visibility for axes to 'off' so it appears transparent
axis(hAxesCM, 'off')
%set colormap for contourm axes
colormap(hAxesCM,hot);
%plot contourm
% Create a grid of latitude and longitude
[TA, TS] = meshgrid(linspace(min(Ta1), max(Ts1)),linspace(min(Ta1), max(Ts1)));
% Use griddata to compute ozone for each grid point
COMF1 = griddata(Ta1, Ts1, COMF, TA, TS);
% Call contourm
contourmPlot= contourm(TA, TS, COMF1, 5);
%create color bar and set range for color
cbCM = colorbar(hAxesCM,'Location','east');
caxis(hAxesCM,[min(min(COMF1)) max(max(COMF1))]);
%link the two overlaying axes so they match at all times to remain accurate
As you can see from the seperate figures, the contourm plot should be at the same high in the graph as the peaks in the 'background' plot. However, I'm getting the following figure as a result of this code. I can someone help me to fix this problem? I'm clearly doing something wrong here.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

KSSV am 22 Dez. 2016
Bearbeitet: KSSV am 22 Dez. 2016
I have not gone through your code. I suggest you to check the given links, with which you can solve your problem on your own. You have two options:
1. Use two different axis and plot the colormaps
2. Plot first color map, freeze the colormap and plot the second one.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

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!