How to plot black line contours on an already plotted contourf plot?

22 ビュー (過去 30 日間)
Ron Nativ
Ron Nativ 2020 年 6 月 21 日
コメント済み: Milligen 2025 年 8 月 13 日
Hello all,
I have two matrices with the same dimensions. I would like to plot the first one as a colored contourf plot. Then, I want to plot the second matrix as, say, black line contoures on the first plot. Using 'hold on' however does not work in this case as the first plot is simply being runned over. How can I do this?
At the moment I use the following for the first contourf plot
figure1 = figure('InvertHardcopy','off','Color',[1 1 1]);
Y = var1;
X = var2;
Z = velocity;
%
L = 100;
x = linspace(min(X),max(X),L);
y = linspace(min(Y),max(Y),L);
[Xi,Yi] = meshgrid(x,y);
Zi = griddata (X,Y,Z1,Xi,Yi);
contourf(Xi,Yi,Zi)
Thanks in advance,
Ron

回答 (1 件)

darova
darova 2020 年 6 月 21 日
This should be helpfull
[x,y,z] = peaks(20);
contourf(x,y,z,-6:2:6,'linew',2)
hold on
contour(x,y,z,[2 2],'r','linew',3)
hold off
  7 件のコメント
darova
darova 2020 年 6 月 21 日
Impossible
Milligen
Milligen 2025 年 8 月 13 日
If the z range of the second array is outside the z range of the first array, the color scale will be reset to accommodate the increased range. Since you don't want that, simply rescale the second z array to lie within the range of the first z array.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by