Issue with long titles printing in 300 dpi on Matlab 2014b
Show older comments
If you use Matlab 2014b, try this:
figure
aa='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
whos aa
title(aa)
print('-r300', '-dpng',filename) % choose a file name
Name Size Bytes Class Attributes
aa 1x39 78 char
That works fine on the png. Now add one more character in the title:
aa='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab';
whos aa
title(aa)
print('-r300', '-dpng',filename) % choose a file name
Name Size Bytes Class Attributes
aa 1x40 80 char
The title does not appear properly on the png format, but it does if you remove the -r300 option, is that a bug and/or is there a way to circumvent that issue?
Many thanks, Jean-Noel
1 Comment
Steven Ricks
on 20 Aug 2015
This is a bug, but it is apparently only a problem on certain operating systems. I saw this behavior on Windows Server 2008 R2 SP1. I submitted a service request to MathWorks, and they were able to reproduce the problem on the same OS. They are working on a fix. That is all I know. In the meantime, I have broken my long figure titles into two lines as follows:
title(sprintf('%s\n%s', firstLine, secondLine))
As long as each line is short enough, the title will appear properly in the png.
Answers (1)
Mike Garrity
on 20 Aug 2015
If you call
opengl info
there's a value in the output named MaxTextureSize.
My guess is that this is really low on your system. In fact, my guess is that it is 1,024 on your system. The reason for that guess is that on my system, this code:
aa='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab';
title(aa)
t=get(gca,'Title')
t.Units='pixels';
ex=t.Extent;
width = ex(3)
returns 335. If we take that number and do the following:
width * 300 / get(groot,'ScreenPixelsPerInch')
we get 1,047.
The bug is that when the width of a text string exceeds the system's maximum texture size, we need to break the string into several tiles, or reduce the resolution of the texture. The current version of the code isn't doing either of those.
So that's how OpenGL printing works. One option here would be to add
-painters
to your print command. In that case it wouldn't care about the OpenGL texture size limit.
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!