Figure 10-2: Drawing Shapes

Portfolio Categories: All Graphics and SGR Book Graphics.

fig-10-2-Adding obs


# Figure 10-B - rbind() --------------------------------------------------------

png(filename = "illustrations/fig-10-2-Adding obs.png",    
  units = "in",                        # Set units to inches
  width = 6,                           # Set a width of 6 inches
  height = 4,                          # Setheight to 4 inches
  res = 1200,                          # Set resolution to 1200
  pointsize = 12)                      # Set text pointsize to 12

par(mar = c(0, 0, 0, 0))               # Set margins to 0 on all sides

plot.new()                             # Start a plot
rect(xleft = 0, ybottom = .3,          # Draw a rectangle with coordinates
  xright = 1, ytop = .9)               #  based on percentage of the plot area
rect(xleft = 0, ybottom = 0,
  xright = 1, ytop = .25)     
text(x = .05, y = .85,                 # Add the text
  cex = .75, adj = c(0,1),             # Lined up left and below point
  labels = "School A\nSchool B\n.\n.\n.")
text(x = .05, y = .2,                  # Add the text
  cex = .75, adj = c(0,1),             # Lined up left and below point
  labels = "New School C\nNew School D") 
  text(x = .5, y = .95,                # Add title, centered above point
    adj = c(.5, 0), 
  labels = "Performance Metrics by School")     
text(x = .5, y = .275, cex = 1.5, labels = "+")     

dev.off()                              # Output png file