Filter löschen
Filter löschen

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

24 Ansichten (letzte 30 Tage)
Erwin Avendaño
Erwin Avendaño am 2 Dez. 2019
Kommentiert: Image Analyst am 3 Dez. 2019
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

Antworten (1)

Image Analyst
Image Analyst am 3 Dez. 2019
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 Kommentare
Erwin Avendaño
Erwin Avendaño am 3 Dez. 2019
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 am 3 Dez. 2019
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);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by