How could I move my xlabel in the center to the right?

조회 수: 12 (최근 30일)
Erwin Avendaño
Erwin Avendaño 2019년 12월 2일
댓글: Image Analyst 2019년 12월 3일
onda.png
As you can see "Grados" is on the lower left, I would like to move it to the center. I mean in the same line but towards the center, how could it? thank you very much
function arduinomatlab
v1=zeros(1,1000);
v2=zeros(1,1000);
delete(instrfind({'Port'},{'COM3'}));
s = serial('COM3','BaudRate',9600,'Terminator','CR/LF');
warning('off','MATLAB:serial:fscanf:unsuccessfulRead');
fopen(s);
muestras=1;
figure('Name','Captura');
xlh = xlabel ( 'Grados' );
xlh.Position (2) = xlh.Position (2) - 1.1;
ylim([-1 1]);
xlim([0 369]);
ax = gca;
ax.XAxisLocation = 'origin';
ylabel('Y')
title('Onda Sinouidal')
grid on
hold on
while 1
xticks([30,60,90,120,150,180,210,240,270,300,330,360])
try
valor=fscanf(s, '%f,%f')';
v2(muestras)=(valor(2));
v1(muestras)=(valor(1));
plot(v2(1:muestras),v1(1:muestras),'-k')
drawnow
muestras=muestras+1;
catch
break
end
end
fclose(s);
delete(s);
clear s;
end

답변 (1개)

Image Analyst
Image Analyst 2019년 12월 3일
Delete the line where you manually position it:
xlh.Position (2) = xlh.Position (2) - 1.1;
then I think it should remain at its automatically-determined location (i.e. centered).
  댓글 수: 2
Erwin Avendaño
Erwin Avendaño 2019년 12월 3일
No, it is not like that. It is located in the center of the graph to the right. And I wish it was down the graph but centered
Image Analyst
Image Analyst 2019년 12월 3일
It seems to be caused by this line:
ax.XAxisLocation = 'origin';
If you comment that out it will be centered. You can use line() to draw an x axis but the tick labels won't be there:
line(xlim, [0, 0], 'Color', 'k', 'LineWidth', 2);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by