Remove only axis lines without affecting ticks and tick labels

前端 未结 4 951
渐次进展
渐次进展 2020-12-09 00:07

Is there a way to remove only the axis lines in the Matlab figure, without affecting ticks and tick labels.

I know that box toggles the upper and righ

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 01:05

    There is another undocumented way (applicable to MATLAB R2014b and later versions) of removing the lines by changing the 'LineStyle' of rulers to 'none'.

    Example:

    figure;
    plot(1:4,'o-');  %Plotting some data
    pause(0.1);      %Just to make sure that the plot is made before the next step
    hAxes = gca;     %Axis handle
    %Changing 'LineStyle' to 'none'
    hAxes.XRuler.Axle.LineStyle = 'none';  
    hAxes.YRuler.Axle.LineStyle = 'none';
    %Default 'LineStyle': 'solid', Other possibilities: 'dashed', 'dotted', 'dashdot'
    


    This is different from Dan's answer which uses the 'visible' property of rulers.

提交回复
热议问题