How to insert Bold text in to image??

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

You can do this with:
figure1 = figure;
annotation(figure1,'textbox',[0.1 0.5 0.1 0.06],'String',{'test'},'FontWeight','bold');
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.
Thanks for Stijn Haenen and Adam Danz's answer. But my task is to insert text into the image and save them as one new image.
Thus, in Matlab platform, it seems that I can only use the insertText function to insert.
However, insertText function doesn't support text type, such as Bold, Italics, Underline....
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.

Sign in to comment.

Answers (1)

Nick
Nick on 14 Aug 2025
Moved: Walter Roberson on 14 Aug 2025
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

Tags

Asked:

on 20 Jun 2020

Moved:

on 14 Aug 2025

Community Treasure Hunt

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

Start Hunting!