Shift the z -value of contour plot in Matlab 2014b

前端 未结 3 1266
花落未央
花落未央 2021-01-23 11:28

I\'m trying to make a figure of a surface plot, and beneath the surface I wish to show the contour lines, but I want the contour to be at z = -1 instead of at the d

3条回答
  •  渐次进展
    2021-01-23 12:29

    I figured out how to solve the problem with color mappings the user Kine faced. Note: I've done the following code on MATLAB R2015b:

    offset = 0.5;
    plotHandle = surfc(X1, Y1, Z1);
    hold on;
    % This line moves the surface up from its original location and increases the space between the surface and the contour plot
    plotHandle(1).ZData = plotHandle.ZData + offset;
    % However in doing so the color mappings are changed. So, the line below restores these mappings
    plotHandle(1).CData = plotHandle.CData - offset;
    
    % This line changes fills the contour plot
    plotHandle(2).Fill = 'on';
    grid on;
    
    % The following lines draw critical areas on the contour line, as it was more readable in my case
    axisHandle = gca;
    ZHeight = axisHandle.ZLim(1);
    plot3(X2, Y2, ZHeight, 'o', 'MarkerSize', 10, 'LineWidth', 1, 'Color', 'k', 'MarkerFaceColor', 'm');
    plot3(Y2, X2, ZHeight, 'o', 'MarkerSize', 10, 'LineWidth', 1, 'Color', 'k', 'MarkerFaceColor', 'm');
    
    hold off
    

提交回复
热议问题