Replace X and Y labels
1 view (last 30 days)
Show older comments
Hi guys
I'm dealing with a simple issue, how can I replace y label so it will be at the top of the y-axis, and x-label will be at the end of the x-axis?
The code:
* *
* * h=figure('Visible','on');
* *
* * for i=1:length(PD)/10:length(PD)
* * plot(J,Kt6(i,:))
* * hold on
* * plot(J,10*Kq10(i,:),'r--')
* * %plot(J,Ktk,'k')
* * plot(J,No(i,:))
* * grid on
* * axis([0 1.6 0 1])
* * xlabel('J')
* * ylabel({'K_t';'10K_Q';'\eta'},'rot',0)
%fname = 'C:\\fig';
%saveas(h, fullfile(fname, 'PropellerUktk'), 'jpeg');
%saveas(h, fullfile(fname, 'PropellerUktk'), 'fig');
Thanks
Isa
0 Comments
Accepted Answer
dpb
on 7 Apr 2014
Edited: dpb
on 7 Apr 2014
Save the handle of the label when you write it and then adjust the position and probably the horizontalalignment properties...
axis([0 1.6 0 1])
hXL=xlabel('J');
pXL=get(hXL,'position'); pXL(1)=1.6; % adjust to right axis limit
set(hXL,'position',pXL,'horizontalalign','right')
hYL=ylabel({'K_t';'10K_Q';'\eta'},'rot',0);
pYL=get(hYL,'position'); pXL(2)=1; % adjust to top axis limit
set(hYL,'position',pYL,'horizontalalign','right')
As always, "Salt to suit"...
More Answers (1)
David Sanchez
on 7 Apr 2014
Taka a look at the following code and adapted to your needs:
x = -pi:.1:pi;
y = sin(x);
h = plot(x,y)
set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'})
title('Sine Function');
xlabel('Radians','FontSize',12,...
'FontWeight','bold','Color','r','Rotation',0,...
'Units','Pixels','Position',[600 0]);
ylabel('Function Value','FontSize',12,...
'FontWeight','bold','Color','r','Rotation',0,...
'Units','Pixels','Position',[0 400])
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!