how exactly works axis label position and extent?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to place horizontal y axis labels so they do not overlap with axes and keep nicely preserved for print. Small example:
figure();
subplot(2,1,1);
plot(rand(10,1));
h = zeros(2,1);
h(1) = ylabel({'Short';'label'});
subplot(2,1,2);
plot(rand(10,1));
h(2) = ylabel({'This is a long';'label of y axis'; 'three-lined'});
set(h,'Rotation',0);
To resolve the problem, I reposition axes to the right to make space:
hxs = get(gcf,'children');
apo = get(hxs,'position');
apo = cell2mat(apo);
marga = 1 - (apo(1,1) + apo(1,3));
npo = apo;
npo(:,1) = apo(:,1) + 0.8*marga;
for ii = 1:length(hxs)
set(hxs(ii),'position',npo(ii,:));
end
clear ii;
I reposition the labels. Based on what I could find in documentation and internet, I only know to do it ad hoc way:
lpo = get(h,'position');
lpo = cell2mat(lpo);
adj = 0.8;
nlp = lpo;
nlp(:,1) = lpo(:,1) - adj;
for ii = 1:length(h)
set(h(ii),'position',nlp(ii,:));
end
Looking on the labels extent and position, I come up with a guess for "adj" of 0.8.
Instead of guessing, I want to derive a good "adj" based on the dimensions of the labels and/or objects these relate to.
Please can someone explain what is axis label position and extent? What are the units? What do they relate to, axes, and how?
Thank you.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!