在图线的顶部绘制带有框架,刻度线的Matlab图 [英] Draw Matlab graphs with frame, ticks, on top of graph lines
问题描述
考虑类似
figure
plot(sin(0:0.01:pi))
axis tight
set(gca,'box','on','ticklength',[0.02 0.05])
然后将图形导出为PDF或其他格式.图形的线在刻度标签和轴的顶部上. (此外,轴的线未正确交汇,但这是另一回事了.)
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?
推荐答案
尝试:
set(gca, 'Layer','top')
根据文档页面:
层
{bottom} | top
在图形对象上方或下方绘制轴线.确定是否 在上面绘制轴线和刻度线 上或下轴的子对象 任何二维视图(例如,当您 沿着x,y或 z轴).使用此属性放置 网格线和顶部的刻度线 图片.
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.
为了直观地看到效果(放大1200%),我将图形另存为PDF文件:
and to visually see the effect (zoomed in 1200%), I save the figure as a PDF file:
默认(图层=底部):
with Layer = top:
with Layer=top:
这篇关于在图线的顶部绘制带有框架,刻度线的Matlab图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!