Stories

Discover boundless stories from unique narrators (storytellers 🙃)

R plotting arguments quiz (regular difficulty)

17501 • Apr 12, 2025

This is the mock questions adapted for Section B of ISDS Final Exam

Description: Fill in the blank with the correct argument name for each plotting task. For each question, identify what argument should replace "argument_x" to achieve the described effect.


  1. To set the color of bars in a histogram:

    hist(mtcars$mpg, "argument_x" = "lightblue")
    
  2. To specify the plot title:

    plot(dist ~ speed, data = cars, "argument_x" = "Stopping Distance Relative to Car Speed")
    
  3. To add a horizontal line at a specific y-value:

    abline("argument_x" = 80, col = "blue")
    
  4. To specify the fill color for boxes in a legend (not border color):

    legend("topright", legend = course, "argument_x" = c("blue", "green", "yellow", "red"))
    
  5. To increase the size of plot symbols (points):

    plot(dist ~ speed, data = cars, "argument_x" = 1.8)
    
  6. What function do you call to finish writing a plot to a file?

    pdf(file = "InsectSpraysBoxplot.pdf", width = 8, height = 5)
    boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
    "argument_x"()
    
  7. To set the background color of plot points (requires pch=21-25):

    plot(dist ~ speed, data = cars, pch = 21, "argument_x" = "pink")
    
  8. To set the line width in abline():

    abline(lm(dist ~ speed, data = cars), "argument_x" = 3)
    
  9. To specify the text entries in a legend:

    legend("top", "argument_x"=c("Tesla", "Facebook"), col=c("#cc33ff", "#0000ff"), lty=1:2)
    
  10. To set the box type in a 3D scatter plot:

    scatter3D(x, y, z, "argument_x" = "g", main ="Iris data")
    
  11. To specify what type of plot to create (line, point, both):

    plot(y ~ x, data = linePlotDat, "argument_x" = "l")
    
  12. To adjust the text size in a legend:

    legend("topright", legend = course, fill = c("blue", "green", "yellow", "red"), "argument_x" = 0.6)
    
  13. To specify the subtitle below the main title:

    plot(dist ~ speed, data = cars, main = "Scatterplot", "argument_x" = "Cars")
    
  14. To set the alpha (transparency) value in an RGB color:

    c1 <- rgb(173,216,230,max = 255, "argument_x" = 100, names = "lt.blue")
    
  15. What function creates a pie chart?

    "argument_x"(x = students, labels = course, main = "ISDS students by course type")
    
  16. To set the number of breaks in a histogram:

    hist(mtcars$mpg, "argument_x" = 10)
    
  17. To increase the size of axis labels:

    plot(dist ~ speed, data = cars, "argument_x" = 1.25)
    
  18. What argument do you need to add a fitted regression line to a scatter plot?

    "argument_x"(lm(dist ~ speed, data = cars))
    
  19. To set the line type (dashed, dotted, etc.) in abline():

    abline(lm(dist ~ speed, data = cars), "argument_x" = 5)
    
  20. To set the color of points in a scatter plot:

    plot(dist ~ speed, data = cars, "argument_x" = "blue")
    
  21. To set the y-axis limits in a plot:

    plot(mH, col = c1, "argument_x" = c(0,50))
    
  22. To specify the colors in a legend:

    legend("top", legend=c("Tesla", "Facebook"), "argument_x"=c("#cc33ff", "#0000ff"), lty=1:2)
    
  23. To increase the size of the main title:

    plot(dist ~ speed, data = cars, "argument_x" = 2.0)
    
  24. To set the maximum value for RGB components:

    c1 <- rgb(173,216,230,"argument_x" = 255, alpha = 100, names = "lt.blue")
    
  25. To add a histogram to an existing plot:

    plot(mH, col = c1, ylim = c(0,50))
    plot(fH, col = c2, "argument_x" = TRUE)
    
  26. To set the file name when saving a plot as PDF:

    pdf("argument_x" = "InsectSpraysBoxplot.pdf", width = 8, height = 5)
    
  27. To increase the size of axis numbers:

    plot(dist ~ speed, data = cars, "argument_x" = 1.1)
    
  28. To specify the line types in a legend:

    legend("top", legend=c("Tesla", "Facebook"), col=c("#cc33ff", "#0000ff"), "argument_x"=1:2)
    
  29. To set the color of a line in abline():

    abline(lm(dist ~ speed, data = cars), "argument_x" = "red")
    
  30. To position a legend in a specific location:

    "argument_x"("top", legend=c("Tesla", "Facebook"), col=c("#cc33ff", "#0000ff"), lty=1:2)
    
  31. To set the plot character/symbol type:

    plot(dist ~ speed, data = cars, "argument_x" = 21)
    
  32. To assign names to colors in the rgb() function:

    c1 <- rgb(173,216,230,max = 255, alpha = 100, "argument_x" = "lt.blue")
    
  33. To specify the label for the x-axis:

    plot(dist ~ speed, data = cars, "argument_x" = "Speed (mph)")
    
  34. What function do you need to add a second line to an existing plot?

    plot(x = index(tesla), y = tesla[,6], type = "l", col="#cc33ff")
    "argument_x"(x = index(fb), y = fb[,6], type = "l", col="#0000ff")
    
  35. To set the title of a legend:

    legend("topright", legend = course, fill = c("blue", "green", "yellow", "red"), "argument_x" = "Course")
    
  36. To set the names for the values in the pie chart:

    pie(x = students, "argument_x" = course, main = "ISDS students by course type")
    

Answers

Click to reveal answers
  1. "col"
  2. "main"
  3. "h"
  4. "fill"
  5. "cex"
  6. "dev.off"
  7. "bg"
  8. "lwd"
  9. "legend"
  10. "bty"
  11. "type"
  12. "cex"
  13. "sub"
  14. "alpha"
  15. "pie"
  16. "breaks"
  17. "cex.lab"
  18. "abline"
  19. "lty"
  20. "col"
  21. "ylim"
  22. "col"
  23. "cex.main"
  24. "max"
  25. "add"
  26. "file"
  27. "cex.axis"
  28. "lty"
  29. "col"
  30. "legend"
  31. "pch"
  32. "names"
  33. "xlab"
  34. "lines"
  35. "title"
  36. "labels"
...