Colour range in a surfplot
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am trying to create a surfplot by using the following dataset:
X = [0.6944 1.0417 1.3889 1.7361 2.0833;
0.6944 1.0417 1.3889 1.7361 2.0833;
0.6944 1.0417 1.3889 1.7361 2.0833;
0.6944 0.7639 0.8333 1.0417 1.3194
0.6944 0.7639 0.8333 NaN NaN];
Y = [100 100 100 100 100;
80 80 80 80 80;
50 50 50 50 50;
30 30 30 30 30;
20 20 20 20 20];
Z = [9.9154 9.9154 13.2126 16.5108 19.6816;
9.9723 17.3669 18.0949 22.1746 26.1141;
2.5790 3.3976 4.2679 17.8651 79.8182;
8.9384 13.1504 17.8445 35.8271 114.3840;
48.1118 66.3772 82.9677 NaN NaN];
The code for the figure is as follows:
figure
surf(X,Y,Z)
colorbar
colormap(viridis)
xlabel('X','FontSize', 16)
ylabel('Y','FontSize', 16)
zlabel('Z','FontSize', 16)
ax = gca;
ax.FontSize = 14;
figure
contourf(X,Y,Z)
colorbar
colormap(viridis)
xlabel('X','FontSize', 16)
ylabel('Y','FontSize', 16)
zlabel('Z','FontSize', 16)
ax = gca;
ax.FontSize = 14;
The two figures I obtained are shown below:
My question is:
The colour range in the first figure cannot be visualised properly due to the small dataset in the green and yellow ranges (see dataset and Figure 2). Is there a solution to resolve this problem? I have tried several other solutions such as caxis and meshgrid, but none of these solutions can help in improving the visualisation in the first figure.
Thank you for your suggestions in advance.
0 个评论
采纳的回答
Kelly Kearney
2019-4-23
By default, a surf plot uses faceted shading, which means that each face is a solid color, determined by a single vertex in that face. To get similar coloring as the contour plot, try interpolated shading instead:
figure
s = surf(X,Y,Z)
colorbar
colormap(viridis)
xlabel('X','FontSize', 16)
ylabel('Y','FontSize', 16)
zlabel('Z','FontSize', 16)
ax = gca;
ax.FontSize = 14;
shading interp;
set(s, 'edgecolor', 'k'); % if you still want the face edges visible
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!