Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab labeling, plots, legends

Tags:

legend

matlab

How do I get my legend entry to have an underscore in the name without MATLAB thinking I want the underscore to mean subscript?

like image 456
dewalla Avatar asked Apr 07 '11 17:04

dewalla


2 Answers

One option, if you don't intend to use any TeX or LaTeX formatting for your legend strings, is to set the 'Interpreter' property for the legend object to 'none'. There are two ways to do this:

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
like image 159
gnovice Avatar answered Sep 25 '22 23:09

gnovice


You'll have to escape the underscore with a backslash \ as legend('foo\_bar')

like image 28
abcd Avatar answered Sep 24 '22 23:09

abcd