How to insert Bold text in to image??
Show older comments
I find that the current function 'insertText' doesn't support to insert Bold type or Italics type text.
How can I choose to insert Bold or not Bold text ?
4 Comments
Stijn Haenen
on 20 Jun 2020
You can do this with:
figure1 = figure;
annotation(figure1,'textbox',[0.1 0.5 0.1 0.06],'String',{'test'},'FontWeight','bold');
Adam Danz
on 20 Jun 2020
annotation() uses normalized coordinates which is sometimes helpful. But if the text should be placed at specific loctations in data coordinates (or pixel coordinates), use text().
text(x,y,'MyText','FontWeight','Bold')
See the documentation for the text function to learn how to center it and change other properties.
桐 唐
on 20 Jun 2020
Adam Danz
on 20 Jun 2020
I see the problem now.
I haven't tried this but perhaps you could use the text or annotation function and save the figure as an image. It seems to be that there should be a better solution but I'm not aware of it at this time.
Answers (1)
Nick
on 14 Aug 2025
Moved: Walter Roberson
on 14 Aug 2025
0 votes
insertText doesn't have a "FontWeight" property like other functions, but it does allow you to specify bold/italic through the "Font" option. For example, to insert bold text with Courier New, you would specify "Font", "Courier New Bold". I'm not sure if it would work for all fonts, though!
Categories
Find more on Configure and View Diagnostics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!