Skip to content

Instantly share code, notes, and snippets.

@gDanix
Created November 8, 2016 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gDanix/c63af39c3f429d08a1bde13da9ac7af4 to your computer and use it in GitHub Desktop.
Save gDanix/c63af39c3f429d08a1bde13da9ac7af4 to your computer and use it in GitHub Desktop.
Código en R que genera una gráfica con el dataset NY.xls
lowest_y = min(min(ny$`Warmest Minimum Temperature (C)`), min(ny$`Coldest Minimum Temperature (C)`))
highest_y = max(max(ny$`Warmest Minimum Temperature (C)`), max(ny$`Coldest Minimum Temperature (C)`))
plot(ny$Year, ny$`Warmest Minimum Temperature (C)`, xlim = c(min(ny$Year), 2015), xlab = "Año", ylab = "Temperatura (ºC)", main = "Temperaturas mínimas más cálidas y frías", xaxt = "n", type = "l", ylim = c(lowest_y, highest_y), col="orange")
lines(ny$Year, ny$`Coldest Minimum Temperature (C)`, xlim = c(min(ny$Year), 2015), type = "l", ylim = c(lowest_y, highest_y), col="cadetblue3")
axis(1, at=seq(1900,2015, 5), cex.axis = 0.5)
abline(h=seq(-10,15,2.5), lty=2)
legend("topleft", legend="Más cálida", col="orange", lty=1, cex=0.6)
legend("bottomleft", legend="Más fría", col="cadetblue3", lty=1, cex=0.6)
@gDanix
Copy link
Author

gDanix commented Nov 8, 2016

Notas:

  • Los valores de xlim están puestos para que el eje x comienze en el menor año y acaben siempre en el 2015.
  • El parámetro cex tan sólo es un factor de escalado: hace que las cosas se muestren más pequeñas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment