在Matlab中正确绘制粗体轴

时间:2015-02-23 23:30:23

标签: matlab plot matlab-figure axes visual-glitch

Matlab图中的默认轴非常薄,我试图用

加粗
set(gca, 'fontsize', 18, 'linewidth', 2)

但是这些线条在四个边缘中没有正确匹配。以下MWE演示了该问题:

plot(1,1,'linewidth', 5)
set(gca, 'fontsize', 18, 'linewidth', 5)
box on
print -dpng example

example with glitch in the edges

如何在Matlab中正确绘制粗体轴?

2 个答案:

答案 0 :(得分:3)

如何使用plot手动绘制四条粗线?

plot(1,1,'linewidth', 5)
hold on
xl = xlim;
yl = ylim;
plot([xl(1) xl(2) xl(2) xl(1) xl(1)],...
     [yl(1) yl(1) yl(2) yl(2) yl(1)],....
     'k', 'linewidth', 5)
set(gca, 'fontsize', 18)
print -dpng example

或者,如@thewaywewalk所述,长plot行可以被更简单的

替换
rectangle('linewidth',5)

Matlab R2010b中的结果:

enter image description here

Matlab R2014a中的结果: enter image description here

Matlab R2014b中的结果:

enter image description here

答案 1 :(得分:-1)

set(findobj(gcf,'type','axes'),'FontName','Helvetica','FontSize',12,'FontWeight','Bold', 'LineWidth', 2)

您现在可以轻松设置任何参数。