Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw Matlab graphs with frame, ticks, on top of graph lines

Tags:

plot

matlab

Consider something like

figure
plot(sin(0:0.01:pi))
axis tight
set(gca,'box','on','ticklength',[0.02 0.05])

then export the graph to PDF or whatever. The lines of the graph are on top of the tick labels and the axes. (Furthermore, the lines of the axes don't meet correctly, but that's another story.)

Is there a way (that can be automated) to have the axes drawn on top?

like image 892
Will Robertson Avatar asked Sep 07 '10 01:09

Will Robertson


1 Answers

Try:

set(gca, 'Layer','top')

according to the documentation page:

Layer

{bottom} | top

Draw axis lines below or above graphics objects. Determines whether to draw axis lines and tick marks on top or below axes children objects for any 2-D view (for example, when you are looking along the x-, y-, or z-axis). Use this property to place grid lines and tick marks on top of images.

and to visually see the effect (zoomed in 1200%), I save the figure as a PDF file:

alt text

Default (Layer=bottom):

alt text

with Layer=top:

alt text

like image 154
Amro Avatar answered Nov 10 '22 05:11

Amro