Replace X and Y labels
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
dpb
le 7 Avr 2014
Modifié(e) : dpb
le 7 Avr 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"...
Plus de réponses (1)
David Sanchez
le 7 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!