Legend with a variable in it

1 visualización (últimos 30 días)
Zhen Liu
Zhen Liu el 13 de Mayo de 2020
Comentada: Zhen Liu el 23 de Mayo de 2020
I am trying to add legend to a plot. The legend is a varibale. Some elemets in the vatiable has underscore (Sample_A1_A2). I used the code below for this purpose.
Name = Table.Properties.VariableNames{i};
legend(Name,'Location','Northwest');
(It is in a for loop. )
The resutled plot legend didn't include the underscore in the name, instead the letters right after the underscore are subscripted.
Any suggestion how I can get pass this?
Thanks.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 13 de Mayo de 2020
Editada: Geoff Hayes el 13 de Mayo de 2020
Zhen - from legend properties you need to set the Interpreter property to none to display literal characters. Try doing
Name = Table.Properties.VariableNames{i};
legend(Name,'Location','Northwest','Interpreter', 'none');
or
Name = Table.Properties.VariableNames{i};
hLegend = legend(Name,'Location','Northwest');
set(hLegend, 'Interpreter', 'none');
  1 comentario
Zhen Liu
Zhen Liu el 23 de Mayo de 2020
Thanks. Solve the problem.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by