How could I move my xlabel in the center to the right?
20 ビュー (過去 30 日間)
古いコメントを表示

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
0 件のコメント
回答 (1 件)
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 件のコメント
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);
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!