Replace X and Y labels
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
dpb
el 7 de Abr. de 2014
Editada: dpb
el 7 de Abr. de 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"...
Más respuestas (1)
David Sanchez
el 7 de Abr. de 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 comentarios
Ver también
Categorías
Más información sobre Title en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!