overlaying 3 contourf plots into 1 figure.

12 views (last 30 days)
I am trying to overlay 3 contourf plots onto 1 Figure. It lets me overlay 3 countour functions, however when i use the contourf command the hold all/on function, only the last mentioned contourf command plots. Any help as to how to overlay 3 contourf functions onto one figure to find a concentrated zone would be great.
%% AOS
x = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9];
y = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9];
[X,Y] = meshgrid(x,y);
Z1 = [ 20.34081392 24.37250891 24.97507193 25.3320617 25.86361835 25.95155349 26.03975216 26.12742332 26.21535847;
25.86361835 29.53301627 32.41450392 33.33644051 34.09038087 34.23716089 34.68277517 34.83061 35.12313806;
27.85695058 32.72181463 36.13086531 37.66297511 38.60663353 39.52562987 39.91254591 40.29466532 40.79782884;
29.20209971 34.53598871 37.73136069 39.26542877 41.16956783 42.26261789 42.73630019 43.43349074 43.66238178;
29.03502889 33.94043955 37.93301469 40.29466532 41.78170987 42.61788115 43.54837085 44.33871238 45.32410643;
30.02562603 35.12313806 38.73917654 40.67203941 42.73630019 43.88782113 44.66799596 45.85809874 46.17349245;
30.51285594 33.94043955 39.00132404 39.78389555 43.08621792 43.88954071 44.89003382 45.75162783 46.48491736;
31.15532579 35.55828037 39.26542877 41.16956783 43.3177352 44.00183206 45.21682292 46.17349245 47.29877111;
30.35116321 35.84457284 38.87073826 41.65965362 43.43349074 44.33871238 45.21682292 46.06862789 46.38084656;
];
Z2 = [ 22.3657608 23.04964971 23.42651689 23.57688848 23.72657432 23.7994382 24.39679645 24.39679645 24.54475324;
27.91952381 29.70092128 31.03181643 31.42378575 32.06505836 32.70561407 33.33396786 33.82979596 33.89150739;
29.4306933 32.06937509 33.64466148 35.6389189 36.45600328 36.68502639 36.79508911 37.47608418 37.70036788;
30.89995613 33.20858388 35.27908047 36.57085727 36.9154217 37.02890847 37.81789331 38.36514962 38.6975031;
31.94040153 34.19811175 35.52060497 37.47946974 37.81654706 38.03879146 38.47926385 38.91573658 39.23814118;
31.81214793 34.80442323 36.10799989 36.9154217 37.48217833 37.70643798 38.14823986 38.47926385 39.02123142;
31.94040153 33.95020171 36.22423093 36.68639858 37.14171545 37.36937135 38.48059334 38.37047876 39.44981526;
32.32516327 33.82837461 35.99107681 36.68639858 37.59295651 37.81654706 37.92867688 38.59004174 39.70643798;
31.55348006 34.92483925 36.22423093 36.34046196 36.79851316 37.92867688 37.92666164 38.37047876 39.77025644;
];
Z3 = [ 17.55828719 17.08954115 16.96964906 16.92104128 16.89822447 16.90695446 16.92730179 16.90444216 16.90612461;
16.95964152 16.31558727 16.05911242 15.93075111 15.83218504 15.77216575 15.74583286 15.71551726 15.69162047;
16.70386805 15.98165235 15.53781606 15.30979097 15.14772289 15.0233623 14.96789243 14.87807318 14.83966933;
16.54038568 15.7671128 15.36027788 15.02094184 14.81973781 14.62297719 14.45104332 14.41875586 14.32076271;
16.46200392 15.72915075 15.23574098 14.94910646 14.64608813 14.44409943 14.36261237 14.14953732 14.0882703;
16.38320664 15.66849092 15.18204422 14.86443673 14.61296019 14.36668809 14.20871021 14.04608014 13.98231736;
16.3533482 15.68143956 15.21099661 14.8535255 14.54681624 14.35555537 14.21931312 14.01941146 13.89188118;
16.40238597 15.64570158 15.18206696 14.85343749 14.56395106 14.39417717 14.16417904 14.0963621 13.86644843;
16.37693786 15.65769043 15.16439849 14.58113845 14.81035664 14.42793975 14.22662616 14.03747035 13.96762927;
];
contour(X,Y,Z1)
hold all
contour(X,Y,Z2)
hold all
contour(X,Y,Z3)
hold all
xlabel('Rolling Resistance')
ylabel('Friction Factor')

Accepted Answer

Cris LaPierre
Cris LaPierre on 4 Aug 2020
All 3 contourf plots are there. You can verify this with the plot browser. You do only see the one that was plotted last. The levels all appear the same color because the color axis is fitting the range of all the data, which goes up to 45.
Since these are filled contour plots, you cannot see through them like you could with contour. There does not appear to be a transparency option here.
Perhaps you just need to consider other visualizations. Perhaps a 3D scatter plot?
figure
scatter3(X(:),Y(:),Z1(:))
hold on
scatter3(X(:),Y(:),Z2(:))
scatter3(X(:),Y(:),Z3(:))
hold off
Or maybe surfaces with transparency set?
figure
surf(X,Y,Z1,"FaceAlpha",0.25)
hold on
surf(X,Y,Z2,"FaceAlpha",0.25)
surf(X,Y,Z3,"FaceAlpha",0.25)
hold off

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!