Formatting Legend Entries Properly

16 views (last 30 days)
Michael
Michael on 24 Oct 2014
Commented: Michael on 24 Oct 2014
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');

Accepted Answer

Robert Cumming
Robert Cumming on 24 Oct 2014
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 Comment
Michael
Michael on 24 Oct 2014
Thank you, I'm not sure how I missed that!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by