Advertisement
Guest User

impact crater data plot

a guest
Jul 8th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.69 KB | None | 0 0
  1. iwantpngfiles <- TRUE
  2.  
  3. waitreturn <- function(prompt="Press Return") {
  4.     if (interactive() && !iwantpngfiles) readline(prompt)
  5. }
  6.  
  7. #install.packages("RJSONIO")
  8. library(RJSONIO)
  9. j <- fromJSON("Impact_database_2010_1.json") # or wherever you put it
  10. y <- data.frame(matrix(unlist(lapply(j, function(xx) { row <- c(xx$age, xx$diameter); if (length(row) == 1) { row <- c(row, NA) }; return(row) })), ncol=2, byrow=T))
  11.  
  12. if (iwantpngfiles) {
  13.     png("impact_craters_%01d.png", 500)
  14. }
  15.  
  16. par(mar=c(5, 4, 1, 1))
  17.  
  18. plot(y, xlab="Age [Myr]", ylab="Crater diameter [km]", log="xy", pch="★", xlim=c(2e7, 1e-5), ylim=c(0.01, 1e3), axes=FALSE)
  19. grid()
  20. axis(1, at=10^(-5:7), label=c(expression(10^-5, 10^-4, 10^-3, 10^-2, 0.1, 1, 10, 100, 10^3, 10^4, 10^5, 10^6, 10^7)))
  21. axis(2, at=10^(-2:3), label=c(expression(10^-2, 0.1, 1, 10, 100, 10^3)))
  22.  
  23. waitreturn()
  24.  
  25. plot(y, xlab="Age [Myr]", ylab="Crater diameter [km]", log="xy", pch="★", xlim=c(3e3, 1e-5), ylim=c(0.01, 1e3), axes=FALSE)
  26. grid()
  27. axis(1, at=10^(-5:3), label=c(expression(10^-5, 10^-4, 10^-3, 10^-2, 0.1, 1, 10, 100, 1000)))
  28. axis(2, at=10^(-2:3), label=c(expression(10^-2, 0.1, 1, 10, 100, 10^3)))
  29.  
  30. waitreturn()
  31.  
  32. plot(y, xlab="Age [Myr]", ylab="Crater diameter [km]", log="xy", pch="★", xlim=c(3e3, 1e-5), ylim=c(0.01, 1e3), axes=FALSE)
  33. grid()
  34. axis(1, at=10^(-5:3), label=c(expression(10^-5, 10^-4, 10^-3, 10^-2, 0.1, 1, 10, 100, 1000)))
  35. axis(2, at=10^(-2:3), label=c(expression(10^-2, 0.1, 1, 10, 100, 10^3)))
  36. curve((1e3*x)^0.5, add=TRUE, lty="dashed")
  37. text(0.01, 200, "anthropic shadow?", cex=2)
  38. curve((x/1e3)^0.5, add=TRUE, lty="dashed")
  39. text(200, 0.03, "too boring\nto record?\neroded away?", cex=1.5)
  40.  
  41. if (iwantpngfiles) {
  42.     dev.off()
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement