Figure 10-1: Drawing Shapes

Portfolio Categories: All Graphics and SGR Book Graphics.

fig-10-1-Adding variables


# Figure 10.1 - column concatentation
# This is really just about graphics, but as long as it is in the book we might
# as well include the code here	 

# Create a subdirectory under the working directory for illustrations
# dir.create("illustrations")

# Set up an external png file for the new plot
png(filename = "illustrations/fig-10-1-Adding variables.png",  
  units = "in",                        # Set units to inches
  width = 6,                           # Set width to 6 inches
  height = 4,                          # Set height to 4 inches
  res = 1200,                          # Set resolution to 1200 pix/inch
  pointsize = 12)                      # Set pointsize

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

# The plot (just use this if you want the plot in the R graphics window)
plot.new()                             # Start a plot
rect(xleft = .1, ybottom = .1,         # Draw a rectangle with coordinates
	xright = .7, ytop = .8)              #  based on percentage of the plot area
rect(xleft = .8, ybottom = .1,
	xright = .85, ytop =.8)     
text(x = .16, y = .65, cex = .75,      # Add the text
	labels = "School A\nSchool B\n.\n.\n.")
text(x = .4, y = .9, labels = "Performance Metrics\n by School")     
text(x = .825, y = .9, labels = "Demographic\n Data\n by School")     
text(x = .65, y = .9, cex = 1.5, labels = "+")     

dev.off()                              # Output png file