issues with contourf- Color Mapping
13 次查看(过去 30 天)
显示 更早的评论
Hi,
Im having issues with the contourf maps. As you can see from the attached image and matrix. It's showing the majority of the area as dark purple, which corresponds to ~0. However, if you look at the matrix, the majority of the area should have values between 0.3-0.55 (except the left hand side). which means it should be light blue. Why aren't the colors matching up with the data?
Thanks
contourf(tdelt,[0,1])
0 个评论
回答(1 个)
Wine
2017-4-19
Hi,
I guess, it is because of the [0, 1] vector you´ve added. If you try “contourf(tdelt)” most sections are drawn in a light blue.
With the [0,1] you´re drawing a vector which can only differ between zero and one. So every parameter that is lower than 1 is shown as dark blue and every parameter greater one as yellow.
See also the documentation: “contourf(Z,v) draws a filled contour plot of matrix Z with contour lines at the data values specified in the monotonically increasing vector v. To display a single contour line at a particular value, define v as a two-element vector with both elements equal to the desired contour level. For example, to draw a single contour of level k, use contourf(Z,[k k]). Specifying the vector v sets the LevelListMode property to manual.”
Cheers,
Ines
p.s. if you want to try out the differences you can f.e. use the following Code:
figure
contourf(tdelt,[0,1]);
figure
contourf(tdelt);
figure
contourf(tdelt,[0.5,0.5]);
figure
contourf(tdelt,[0, 0.5, 1, 1,5]);
1 个评论
Alberto Mateos Bond
2022-8-14
Hi!
Something similar happened to me.
I have made a contourf interpolating results with meshgrid and it plots a graph which does not correspond to the values that I put as input with the colors of the colorbar (There are points where it should be yellow or red and it is blue, or other points which have markedly different values and are the same color). I don't know if it's a problem with the interpolation method, I think not since I've checked that and the numbers are consistent. I don't see a problem with the contour either. I don't know if I should use another interpolation method and I dont unterstand what exactly is wrong
clear all;clc;
A=[77.3139227401096,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.8499350764564,77.8442382759329,77.8400158037560,77.8367460305253,77.8341382601430,77.3189088790396,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.4228460196533,77.3770975908979,77.3678714954335,77.3624256179988,77.3588314539844,77.3562741687948,77.3543880471537,77.3529118848689,77.3517359358068,77.8230143346564,77.5947167588728,77.4572289300964,77.3536200322737,77.2815354478640,77.1958950775090,77.1462000726089,77.1176650859710,77.1045877194747,77.0939198939992,77.0960045406636,77.0936701640036,77.0918470331206,77.0903910018129,78.9250781251261,78.2607772080247,77.8571819100295,77.5445345646900,77.1777675777582,77.1067936547286,77.0560757369439,77.0204796252278,77.0021470133600,76.9934357792392,76.9874018876342,76.9841903129164,76.9834146935698,76.9832804850934];
torque=[-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100];
rpmrange=[6,6,6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5];
[xmesh,ymesh]=meshgrid(torque,rpmrange);
vq=griddata(torque,rpmrange,A,xmesh,ymesh);
contourf(xmesh,ymesh,vq,1000,'EdgeColor','none')
xlabel('Torque increase [%]');
ylabel('RPM range [*10^3]');
title('Torque Sensivity Study');
hc = colorbar;
set(get(hc,'title'),'string','LapTime [s]')
colormap(flipud(jet))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!