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 right axes lines and ticks and that works perfectly for me.
But my problem is that I want eliminate the bottom and left lines (only lines!) but keeping the ticks and tick labels.
Any tricks?
Yair Altman's Undocumented Matlab demonstrates a cleaner way to do this using the undocumented axes rulers:
A nice feature of this approach is that you can separately format the x and y axis lines.
You could "erase" the axis lines by plotting a white line over them:
Result:
As noted by @SardarUsama, in recent Matlab versions you may need to adjust the line width to cover the axes:
Solution for Matlab versions prior to R2014b
You can introduce a new white bounding box and put it on top.
Important is to deactivate the ticks of the second axes, to keep the ticks of the f rist one.
In Luis Mendo's solution, the plotted lines are fixed and stay at their initial position if you change the axes properties afterwards. That won't happen here, they get adjusted to the new limits. Use the correct handle for every command and there won't be much problems.
Dan's solution is easier, but does not apply for Matlab versions before R2014b.
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:
This is different from Dan's answer which uses the 'visible' property of rulers.