You are here: Vanderbilt Biostatistics Wiki>Main Web>RGraphicsChallenge (revision 1)EditAttach
The R Graphics Challenge is a biweekly task meant to explore the capabilities of R graphics. The challenges will start at the most basic level and work their way up, with the goal of making graphing in R something we are all comfortable doing. The solutions will be posted two weeks after the challenge goes out. Just like there is more than one way to skin a cat, there is more than one way to graph in R. These solutions are just a few ways way to accomplish the tasks. Feel free to contact me for extra tips or to pass on other great solutions!

The "Initial" Challenge Assigned: April 15

For the first challenge, please draw your initial. It can be as pretty or as plain as you want. I would encourage you to see how creative you can get. Maybe try to build a function that will plot it for you. I have added what may be useful functions if you need help getting started.
  • lines
  • segments
  • points
  • axes
  • abline

  ### E with lines ###
  plot(c(0,4), c(0,4), type="n", axes=F,xlab="", ylab="")
  segments(xpts[1:4], ypts[1:4], xpts[5:8], ypts[5:8], col="darkorange2", lty="longdash", lwd=3)

  ### E with points ###
  v<-seq(from=1, to=3, by=.1)
  h1<-seq(from=1, to=2.2, by=.1)
  h2<-seq(from=1, to=1.8, by=.1)
  plot(c(0,4), c(0,4), type="n", axes=F,xlab="", ylab="")
  points(rep(1, length(v)), v, pch="*", cex=3, col=c("deeppink", "cornflowerblue") )
  points(h1, rep(3, length(h1)),pch="*", cex=3, col=c("deeppink", "cornflowerblue") )
  points(h1, rep(1, length(h1)),pch="*", cex=3, col=c("deeppink", "cornflowerblue") )
  points(h2, rep(2, length(h2)),pch="*", cex=3, col=c("deeppink", "cornflowerblue") )

  plot(c(0,4), c(0,4), type="n", axes=F,xlab="", ylab="")
  points(rep(1, length(v)), v, pch="E", cex=1.2, col=c("slateblue4", "turquoise4") )
  points(h1, rep(3, length(h1)),pch="E", cex=1.2, col=c("slateblue4", "turquoise4") )
  points(h1, rep(1, length(h1)),pch="E", cex=1.2, col=c("slateblue4", "turquoise4") )
  points(h2, rep(2, length(h2)),pch="E", cex=1.2, col=c("slateblue4", "turquoise4") )

  ### E with text ###
  plot(c(0,4), c(0,4), type="n", axes=F,xlab="", ylab="", bg="forestgreen")
  text(2,2,"E e", cex=8, col="darkseagreen")

  ### S ###
  t1<-seq(pi, 20*pi/9,0.1)

  s1<-circle(a1,b1,r1, t1)
  s2<-circle(a2,b2,r2, t2)
  plot(c(0,4), c(0,4), type="n", axes=F,xlab="", ylab="")
  points(c(s1$x,s2$x),c(s1$y,s2$y), col="white")
  lines(s1$x, s1$y, col="blue3", lty="longdash", lwd=3)
  lines(s2$x, s2$y, col="blue3", lty="longdash", lwd=3)
  segments(s1$x[length(s1$x)],s1$y[length(s1$y)], s2$x[length(s2$x)],s2$y[length(s2$y)], col="blue3", lty="longdash", lwd=3)
  ### D ###
  d<-circle(1.5,2,1.5, seq(-4.5*pi/8, 4.5*pi/8, by=.1))
  plot(c(0,4), c(0,4), type="n", axes=F,xlab="", ylab="")
  lines(d$x, d$y, col="blue3", lty="longdash", lwd=3)
  segments(1.5, .75,1.5, 3.25, col="blue3", lty="longdash", lwd=3)
Edit | Attach | Print version | History: r2 < r1 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r1 - 29 Apr 2008, ElizabethKoehler

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback