如何使我的图例条目名称中有下划线而不让MATLAB认为我想要下划线作为下标?
如果您不打算对图例字符串使用任何TeX或LaTeX格式设置,则一种选择是将图例对象的'Interpreter'
属性设置为'none'
。有两种方法可以实现这一点:
legend({'foo_bar'},'Interpreter','none'); %# One line, labels in a cell array
%# OR...
hLegend = legend('foo_bar'); %# Create the legend, returning a handle
set(hLegend,'Interpreter','none'); %# Set the property
您需要使用反斜杠\
来转义下划线,如legend('foo\_bar')