Formatting Legend Entries Properly

조회 수: 10 (최근 30일)
Michael
Michael 2014년 10월 24일
댓글: Michael 2014년 10월 24일
Hello, I'm trying to add a legend entry with greek letter (mu & sigma) something like: "A - \sigma_A = 75 um" ... for ABCD. Below is my attempt. Thanks for your help. Truly, Michael
letter = {'A','B','C','D'}
legstr ={};
for box=1:4
% Find deviation, print string in Legend
str{box} = sprintf(... % aiming for: "A - \sigma_A = 75 um", "B - ..."
[letter{box},' - \Sigma_',letter{box},...
' = %.0f \mum'],stdDevData_um(box));
legstr = {legstr, str{box}}
$e$n$d; clear box
xlim([0.5 19.5]);
legend(phh, legstr,'location','best');

채택된 답변

Robert Cumming
Robert Cumming 2014년 10월 24일
When using sprintf you have to cancel the \ operator, to do this use a double \\
str{box} = sprintf(... % aiming for: "A - \sigma_A = 75 um", "B - ..."
[letter{box},' - \\Sigma_',letter{box},...
' = %.0f \mum'],stdDevData_um(box));
  댓글 수: 1
Michael
Michael 2014년 10월 24일
Thank you, I'm not sure how I missed that!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by