Hello, Can you help me to change colour and fontsize using sprintf ?
19 views (last 30 days)
Show older comments
Hello, Can you help me to change colour and fontsize using sprintf ? This is my code . sprintf('Kualitas : Sangat Bagus');
1 Comment
Stephen23
on 8 Apr 2017
@made sutawan: This is not possible: character strings (such as the output of sprintf are simlple arrays of character codes, and do not contain formatting information.
If you want formatted text then you can use a GUI.
Answers (2)
Jan
on 8 Apr 2017
As Stephen has explained already: sprintf creates a string, which is a character vector and doe not contain any information about the color or the font.
To influence the font and color, you have to displays this string anywhere, e.g. in the command window or in a GUI. In the first case there are only limited possibilities, see e.g. https://www.mathworks.com/matlabcentral/fileexchange/24093-cprintf-display-formatted-colored-text-in-the-command-window FEX: cprintf>. If you write to an ASNI terminal, see FEX: txprintf. For GUIs you can use LaTeX formatting, see:
docsearch latex
1 Comment
Matin Salehi
on 9 May 2019
do you know how can i disp a word, like
disp('hello')
but i want to chang its fontsize and color. how cam=n i do that with disp command
Image Analyst
on 8 Apr 2017
Edited: Image Analyst
on 8 Apr 2017
Once you create the string with sprintf() then you can send it to controls like an xlabel, ylabel, title, or text along with options to control the font, size, color, etc. For example
text(x, y, yourString, 'FontSize', 20, 'Color', 'r', 'FontWeight', 'bold');
0 Comments
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!