i followed procedures in this question, , tried setting individual text object larger fonts. here sample code:
hf = figure; set(hf, 'defaultaxesfontsize', 14) hx = axes('parent',hf); [hx,hp1,hp2] = plotyy(hx, rand(10,1),rand(10,1),rand(10,1),rand(10,1),'scatter'); hlx = xlabel(hx(1), 'only half of line show up'); hl1 = ylabel(hx(1), 'not truncated less border'); hl2 = ylabel(hx(2), 'only part of line show up'); ht = title(hx(1), 'too close border');
as can seen in picture, labels truncated border of figure. have drag figure large - contrary desired - in order reveal text.
how can automatically set text box according text font size, small graphs don't cut?
i know can manually setting position
of axes it's kind of manual , guess-and-try. there automatic way calculate margins?
one thing can done calculate increased margin according new text font size. assume know matlab's default font size 10, or otherwise get(hf,'defaultaxesfontsize')
.
then relative position of axes get(hx, 'position')
, gives 4 percentage values. first 2 define left , bottom margin. since it's labels, increasing font size 10 14 means text box should grow 1.4 times. next 2 numbers define size of axis. since text boxes on both sides grow 1.4 times, assuming original size being x, new size 1-[(1-x)*1.4] = 1.4x - 0.4.
suggested workaround:
hf = figure; set(hf, 'defaultaxesfontsize', 14) hx = axes('parent',hf); set(hx, 'position', [1.4 1.4 1.4 1.4].*get(hx, 'position')+ [0 0 -.4 -.4]) [hx,hp1,hp2] = plotyy(hx, rand(10,1),rand(10,1),rand(10,1),rand(10,1),'scatter'); hlx = xlabel(hx(1), 'only half of line show up'); hl1 = ylabel(hx(1), 'not truncated less border'); hl2 = ylabel(hx(2), 'only part of line show up'); ht = title(hx(1), 'too close border');
you may replace manually entered number 1.4
ratio between newly assigned (bigger, hopefully) font size , original size 10.
Comments
Post a Comment