How add multi line title to figure (not to plot)?
10 views (last 30 days)
Show older comments
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 Comments
Answers (2)
dpb
on 26 Jul 2017
Unsupported feature, sorry. Find another task...or change assignor's expectations. :)
2 Comments
dpb
on 26 Jul 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
on 26 Jul 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 Comments
See Also
Categories
Find more on Title 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!