Why axis labels disappear when trying to assign their position?
Mostra commenti meno recenti
In Matlab 2012b I need to move axis labels of my plot arbitrarily. I want this because they are not placed according to my taste by default. I tried the following workaround but I'm wondered why the label disappears no matter what the offset value is.
The modified complete code is:
clc;
clear all;
close all
x=0:0.01:10;
y=10*cos(x)+5*sin(10*x).^2;
fs=[4.5,1.5]; % figure size
%--------------------------------------------------------------------------
fh=figure;
set(fh,'Color','w')
set(fh,'Units','inches','Position',[3 3 fs])
set(fh,'PaperUnits','normalized','PaperSize',[1 1],'PaperPosition',[0 0 1 1])
ah=axes;plot(x,y,'Color',[1 0 0],'LineWidth',1)
hold on;
grid on;
box on
set(ah,'LineWidth',1)
set(ah,'FontName','Calibri','FontSize',10,'FontWeight','bold')
set(ah,'OuterPosition',[0 0 1.0 1.0])
xlh=xlabel('\itTime (s)','Units','normalized');
pos1=get(xlh,'Position');
pos1(1,2)=pos1(1,2)-0.05;
set(xlh,'Position',pos1)
ylh=ylabel('\ity_1');
What exactly want is to get xlabel a little bit closer to the axis. Something that I feel happening is that the label with it's position assigned manually will not be included in axis outer position region anymore. Am I right?
2 Commenti
Jan
il 18 Gen 2014
Please provide some example data, such that we can reproduce your problem.
Pouya Jamali
il 18 Gen 2014
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Axis Labels in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!