How add multi line title to figure (not to plot)?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I have a task to create figure to display the image with title of two rows: the image name as a first row and the second row the statistics “mean = …, max = …., min = …| as second rows. i know create multi line title for plot.
plot(x,y)
title({'first row','Second row'})
but how create two row title for figure? i am trying
figure('Name',{'first row','Second row'})
but get error: Error using figure While setting the 'Name' property of 'Figure': Value must be a string.
Thanks for help
0 commentaires
Réponses (2)
dpb
le 26 Juil 2017
Unsupported feature, sorry. Find another task...or change assignor's expectations. :)
2 commentaires
dpb
le 26 Juil 2017
It's inherent in the underlying OS figure primitives; they don't support that feature in the title. If you'll look at figure properties there's no 'Interpreter' property so that \n isn't recognized and is stripped/ converted to space. Try
>> s=sprintf('%s\n%s','first row','Second row')
s =
first row
Second row
>>
>> figure('Name',s)
>> ft=get(1,'name')
ft =
first row
>>
Note there's only one line displayed on retrieval as opposed to two that were sent. Prove it:
>> double(ft)
ans =
102 105 114 115 116 32 114 111 119
>>
'32' is blank, not '\n'
You're beating a dead horse here. Sometimes you just can't do anything you want no matter how hard you try.
Jan
le 26 Juil 2017
The name of the figure appears in the border of the window. There is only space for a single line. Do you want to the figure title to appear inside the window? This is possible:
figure;
AxesH = axes('Units', 'normalized', 'Position', [0,0,1,1], 'Visible', 'off');
text(0.5, 1, {'First line', 'second line'}, 'Parent', AxesH, ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'top');
0 commentaires
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!