Replace X and Y labels
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
dpb
2014-4-7
编辑:dpb
2014-4-7
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"...
更多回答(1 个)
David Sanchez
2014-4-7
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!