Effacer les filtres
Effacer les filtres

Highlighting (make bold or underline) an item in a cellstring to be used in an annotation

58 vues (au cours des 30 derniers jours)
Hi, I want to highlight by either underlining or making bold or different color only one cell string in the annotation:
In the code, newname is a string and the item I want highlighted.
dim = [0.4 0.1 0.2 0.1];
str = {newname,['<Mean>=',num2str(mna,'%.2f')],['<CutOff>=',num2str(cutoff2,'%.2f')]};
annotation('textbox',dim,'String',str,'FitBoxToText','on', 'BackgroundColor',[0 0 0.7], 'FaceAlpha',0.2,'Units','normalized','HorizontalAlignment','left','FontSize',12);
I have tried the following but no luck.
str = {\bfboldnewname,['<Mean>=',num2str(mna,'%.2f')],['<CutOff>=',num2str(cutoff2,'%.2f')]};
  1 commentaire
Rik
Rik le 5 Jan 2018
As the annotation object has no children, I think the only way to adjust only one line would be to generate the box with annotation, but put in the text separately with text. You might be able to set the annotation box as the parent object, which might spare you some headache with the position.

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
Guillaume le 5 Jan 2018
str = {newname, ['<Mean>=',num2str(mna,'%.2f')], ['<CutOff>=',num2str(cutoff2,'%.2f')]};
str{1} = ['\bf ', str{1}, ' \rm']; %\bf to set to bold, \rm to reset back to normal afterward
annotation('textbox',dim,'String',str,'FitBoxToText','on', 'BackgroundColor',[0 0 0.7], 'FaceAlpha',0.2,'Units','normalized','HorizontalAlignment','left','FontSize',12);
  2 commentaires
Jason
Jason le 5 Jan 2018
Perfect thankyou, can you also change its color? Jason
Jason
Jason le 5 Jan 2018
Done it.
str{1} = ['\bf\color{red} ', str{1}, ' \rm\color{black}'];

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by