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 commentaires

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.
桐 唐
桐 唐 le 20 Juin 2020
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....
Adam Danz
Adam Danz le 20 Juin 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.

Connectez-vous pour commenter.

Réponses (1)

Nick
Nick le 14 Août 2025
Déplacé(e) : Walter Roberson le 14 Août 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!

Catégories

Tags

Question posée :

le 20 Juin 2020

Déplacé(e) :

le 14 Août 2025

Community Treasure Hunt

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

Start Hunting!

Translated by