Hi,
I am trying to include a single letter with an 'over-bar' after the percentage sign in the following code for a legend on a plot:
legend('CG = 33.46%','string2' )
If anyone has an idea of how to do this, then that would be really great.
Thanks,
Robbie

 채택된 답변

the cyclist
the cyclist 2012년 1월 24일

6 개 추천

plot(1:10)
h = legend('$$\overline{x}$$')
set(h,'Interpreter','latex','fontsize',24)

댓글 수: 6

Robbie
Robbie 2012년 1월 24일
Hi, Thanks for your response. I can get this working but I can't get it 'embedded' within another string. I want something of the form 'string' followed by the x 'over-bar' in the legend. I get an error of the form:
Warning: Unable to interpret TeX string
Any suggestions?
Thanks,
Robbie
the cyclist
the cyclist 2012년 1월 24일
편집: the cyclist 2017년 3월 28일
Like this?
h = legend(['before ','$$\overline{x}$$',' after'])
set(h,'Interpreter','latex','fontsize',24)
Carlo Ruzzo
Carlo Ruzzo 2017년 3월 28일
After more than five years, I had the same problem and I found your answer very useful. Thnak you very much! Carlo
Nathaniel Werner
Nathaniel Werner 2017년 7월 31일
I have a related question.
I am generating some plots where the symbol 'x' changes in the legend depending on what I am plotting. For one figure I have a string that defined symbol = '\omega_r^*'. How can I put an overbar over that instead of x?
Thanks
the cyclist
the cyclist 2017년 7월 31일
편집: the cyclist 2017년 7월 31일
symbol = '\omega_r^*';
h = legend(['before ','$$\overline{',symbol,'}$$',' after'])
set(h,'Interpreter','latex','fontsize',24)
Notice that the general technique here is to take a series of characters and concatenate them -- where one (or more) of the character arrays is predefined in a variable.
When I do that I like to build up from a completely manual version of the character, like ...
s = 'I am a character array'; % Nothing special
s = ['I am a character array']; % Concatenating, but no variables yet
s = ['I am a ','character array']; % Split the character array
s = ['I am a ','character',' array']; % Split again
and then finally
c = 'character';
s = ['I am a ',c,' array']; % Insert one portion from a variable
vidyadhar k
vidyadhar k 2018년 7월 2일

Hello, the cyclist. I have a question too. I want to insert $\mathbf{\overline{Nu_{s}}}$ inside sprintf{' ') to get an overline on Nu. I am getting the error as Warning: Escaped character '\m' is not valid. See 'doc sprintf' for supported special characters

Any help would be appreciated. Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2012년 1월 24일

댓글:

2018년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by