adding two ticks to form a horizontal line

How do I add two ticks in the plot editor so that it gives me a perfect horizontal straight line?

Respuestas (2)

Jonas
Jonas el 30 de Jun. de 2021
if you want to add a horizontal line to you plot you can use yline. if you want a ytick at that specific value you can write
yline(3.3614);
yticks(unique([yticks() 3.3614]));

4 comentarios

shahriar sowad
shahriar sowad el 30 de Jun. de 2021
Editada: shahriar sowad el 30 de Jun. de 2021
i have written a code for many figures in a single plot,so i have added hold on command a few times ,so where should i add this 2 lines?
at the end of my code?
shahriar sowad
shahriar sowad el 30 de Jun. de 2021
here is my code,
x0=reshape(b',[1,7001]);
t=linspace(0,1,7001);
Y=fft(b);
Yabs=abs(Y);
plot(a,'b');
hold on
x1=reshape(d',[1,7001]);
t=linspace(0,1,7001);
Y1=fft(x1);
Y1abs=abs(Y1);
plot(Y1abs,'g');
hold on
x2=reshape(f',[1,7001]);
t=linspace(0,1,7001);
Y2=fft(x2);
Y2abs=abs(Y2);
plot(Y2abs,'r');
hold on
x3=reshape(h',[1,7001]);
t=linspace(0,1,7001);
Y3=fft(x3);
Y3abs=abs(Y3);
plot(Y3abs,'k');
hold on
x4=reshape(j',[1,7001]);
t=linspace(0,1,7001);
Y4=fft(x4);
Y4abs=abs(Y4);
plot(Y4abs,'y');
hold on
x5=reshape(l',[1,7001]);
t=linspace(0,1,7001);
Y5=fft(x5);
Y5abs=abs(Y5);
plot(Y5abs,'m');
Jonas
Jonas el 30 de Jun. de 2021
yes, add the two lines at the end of your code.
note that you just need one 'hold on' command, this will have the effect that all later plots are added to the current figure
shahriar sowad
shahriar sowad el 30 de Jun. de 2021
it is showing error as undefined function yline

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 29 de Jun. de 2021

Respondida:

el 30 de Jun. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by