Graph with error bar in R

Asked

Viewed 65 times

-1

Hello,

I’m trying to make a graph on lines and error bars, but the errors are being plotted over the first line, and not on the second.... and my legend is not being printed. Could you see what is wrong? Follows the code:

V_drone = c(.5, 1.0, 1.5, 2.0, 2.5, 3.0)
Tempo_Incremental_Antigo = c(2589.9, 1905.6, 1567, 1324.5, 1218.6,1119)
Tempo_Incremental_Novo = c(2455.5, 1678.5,1370.8,1147.6, 996.59,911);
Tempo_error_A = c(52.35233201, 87.73976673,88.0883395,49.61566573,192.8685591,50.74248713)
Tempo_error_N = c(46.04164781,56.39592184,75.66563876,64.87500803,161.2008043,75.55329245)

plot(V_drone,Tempo_Incremental_Antigo, ylab=expression("Overall Time(s)"),xlab=expression("Drone speed(m/s)"),col="blue", pch=15, ylim=c(0,3500), cex=1.3, type="b")
arrows(V_drone,Tempo_Incremental_Antigo, V_drone, Tempo + Tempo_error_A, length=0.1,angle = 90,col="blue")
arrows(V_drone,Tempo_Incremental_Antigo, V_drone, Tempo - Tempo_error_A, length=0.1,angle = 90,col="blue")

points(V_drone,Tempo_Incremental_Novo, ylab=expression("Overall Time(s)"), pch=15, ylim=c(0,3500), cex=1.3, type="b", col="red")
arrows(V_drone,Tempo_Incremental_Novo, V_drone, Tempo + Tempo_error_N, length=0.1,angle = 90, col="red")
arrows(V_drone,Tempo_Incremental_Novo, V_drone, Tempo - Tempo_error_N, length=0.1,angle = 90, col="red")

legend(20,30,legend=c("Fotossínte", "Condutância estomática"),pch=c(15,16),bty="n")
text(5,30,"Gráfico A")

1 answer

4


The error line problem as I understood it was by the name of the variable of the central value, fixing it the lines are drawn.

The caption problem was the x and y values provided, you were creating it out of the x-axis value of the graph. The same thing for the text.

And recommend when posting something with graphic already post it together that usually facilitate the suggestions :)

V_drone = c(.5, 1.0, 1.5, 2.0, 2.5, 3.0)
Tempo_Incremental_Antigo = c(2589.9, 1905.6, 1567, 1324.5, 1218.6,1119)
Tempo_Incremental_Novo = c(2455.5, 1678.5,1370.8,1147.6, 996.59,911);
Tempo_error_A = c(52.35233201, 87.73976673,88.0883395,49.61566573,192.8685591,50.74248713)
Tempo_error_N = c(46.04164781,56.39592184,75.66563876,64.87500803,161.2008043,75.55329245)

plot(V_drone,Tempo_Incremental_Antigo, ylab=expression("Overall Time(s)"),xlab=expression("Drone speed(m/s)"),col="blue", pch=15, ylim=c(0,3500), cex=1.3, type="b")
arrows(V_drone,Tempo_Incremental_Antigo, V_drone, Tempo_Incremental_Antigo + Tempo_error_A, length=0.1,angle = 90,col="blue")
arrows(V_drone,Tempo_Incremental_Antigo, V_drone, Tempo_Incremental_Antigo - Tempo_error_A, length=0.1,angle = 90,col="blue")

points(V_drone,Tempo_Incremental_Novo, ylab=expression("Overall Time(s)"), pch=15, ylim=c(0,3500), cex=1.3, type="b", col="red")
arrows(V_drone,Tempo_Incremental_Novo, V_drone, Tempo_Incremental_Novo + Tempo_error_N, length=0.1,angle = 90, col="red")
arrows(V_drone,Tempo_Incremental_Novo, V_drone, Tempo_Incremental_Novo - Tempo_error_N, length=0.1,angle = 90, col="red")

legend(2,3000,legend=c("Fotossínte", "Condutância estomática"), pch=c(15,16), col = c("blue", "red"), bty="n")
text(1.75, 3400,"Gráfico A")

Created on 2020-05-12 by the reprex package (v0.3.0)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.