Fading colors in contourf

2 次查看(过去 30 天)
I have some data to process and to do so, I'm using a contourf-function. I would like my plots to have the colors fading into eachother instead of having clear lines between zones. Anyone that can help me with this?
%Processing input
Data = importdata('NH3.txt').data;
Speed = importdata('Speed.txt').data;
[Y,Z] = meshgrid(unique(Data(:,2),'sorted'),flip(unique(Data(:,3),'sorted')));
NH3 = zeros(65); %pre-allocation
U = zeros(65); %pre-allocation
for r = 1:65
for k = 1:65
NH3(r,k) = Data(find(Data(:,2)== Y(k,k) & Data(:,3) == Z(r,r)), 4);
U(r,k) = Speed(find(Speed(:,2)== Y(k,k) & Speed(:,3) == Z(r,r)), 4);
end
end
%Plotting
subplot(1,2,1)
contourf(Y, Z, NH3, 'Linecolor', 'none')
colorbar
title('NH_3 concentratie [kg/m³]')
xlabel('y [m]')
ylabel('z [m]')
subplot(1,2,2)
contourf(Y, Z, U, 'Linecolor', 'none')
colorbar
title('Snelheid in x-component [m/s]')
xlabel('y [m]')
ylabel('z [m]')

采纳的回答

Chunru
Chunru 2021-12-4
%Processing input
Data = importdata('NH3.txt').data;
Speed = importdata('Speed.txt').data;
yy = unique(Data(:,2),'sorted');
zz = flip(unique(Data(:,3),'sorted'));
[Y,Z] = meshgrid(unique(Data(:,2),'sorted'),flip(unique(Data(:,3),'sorted')));
NH3 = zeros(65); %pre-allocation
U = zeros(65); %pre-allocation
for r = 1:65
for k = 1:65
NH3(r,k) = Data(find(Data(:,2)== Y(k,k) & Data(:,3) == Z(r,r)), 4);
U(r,k) = Speed(find(Speed(:,2)== Y(k,k) & Speed(:,3) == Z(r,r)), 4);
end
end
%Plotting
subplot(1,2,1)
imagesc(yy, zz, NH3); hold on
contour(Y, Z, NH3, 'Linecolor', 'k')
colorbar
title('NH_3 concentratie [kg/m³]')
xlabel('y [m]')
ylabel('z [m]')
subplot(1,2,2)
imagesc(yy, zz, U); hold on
contour(Y, Z, U, 'Linecolor', 'k')
colorbar
title('Snelheid in x-component [m/s]')
xlabel('y [m]')
ylabel('z [m]')
  2 个评论
Xander Caerts
Xander Caerts 2021-12-4
Without the lines ('Linecolor', 'none' ), that gives me exactly what I was looking for. Thank you!
DGM
DGM 2021-12-5
If you're after interpolated color with no lines, then you really don't need a contour plot at all. Just use pcolor().

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by