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.
To set the color of bars in a histogram:
hist(mtcars$mpg, "argument_x" = "lightblue")
To specify the plot title:
plot(dist ~ speed, data = cars, "argument_x" = "Stopping Distance Relative to Car Speed")
To add a horizontal line at a specific y-value:
abline("argument_x" = 80, col = "blue")
To specify the fill color for boxes in a legend (not border color):
legend("topright", legend = course, "argument_x" = c("blue", "green", "yellow", "red"))
To increase the size of plot symbols (points):
plot(dist ~ speed, data = cars, "argument_x" = 1.8)
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"()
To set the background color of plot points (requires pch=21-25):
plot(dist ~ speed, data = cars, pch = 21, "argument_x" = "pink")
To set the line width in abline():
abline(lm(dist ~ speed, data = cars), "argument_x" = 3)
To specify the text entries in a legend:
legend("top", "argument_x"=c("Tesla", "Facebook"), col=c("#cc33ff", "#0000ff"), lty=1:2)
To set the box type in a 3D scatter plot:
scatter3D(x, y, z, "argument_x" = "g", main ="Iris data")
To specify what type of plot to create (line, point, both):
plot(y ~ x, data = linePlotDat, "argument_x" = "l")
To adjust the text size in a legend:
legend("topright", legend = course, fill = c("blue", "green", "yellow", "red"), "argument_x" = 0.6)
To specify the subtitle below the main title:
plot(dist ~ speed, data = cars, main = "Scatterplot", "argument_x" = "Cars")
To set the alpha (transparency) value in an RGB color:
c1 <- rgb(173,216,230,max = 255, "argument_x" = 100, names = "lt.blue")
What function creates a pie chart?
"argument_x"(x = students, labels = course, main = "ISDS students by course type")
To set the number of breaks in a histogram:
hist(mtcars$mpg, "argument_x" = 10)
To increase the size of axis labels:
plot(dist ~ speed, data = cars, "argument_x" = 1.25)
What argument do you need to add a fitted regression line to a scatter plot?
"argument_x"(lm(dist ~ speed, data = cars))
To set the line type (dashed, dotted, etc.) in abline():
abline(lm(dist ~ speed, data = cars), "argument_x" = 5)
To set the color of points in a scatter plot:
plot(dist ~ speed, data = cars, "argument_x" = "blue")
To set the y-axis limits in a plot:
plot(mH, col = c1, "argument_x" = c(0,50))
To specify the colors in a legend:
legend("top", legend=c("Tesla", "Facebook"), "argument_x"=c("#cc33ff", "#0000ff"), lty=1:2)
To increase the size of the main title:
plot(dist ~ speed, data = cars, "argument_x" = 2.0)
To set the maximum value for RGB components:
c1 <- rgb(173,216,230,"argument_x" = 255, alpha = 100, names = "lt.blue")
To add a histogram to an existing plot:
plot(mH, col = c1, ylim = c(0,50)) plot(fH, col = c2, "argument_x" = TRUE)
To set the file name when saving a plot as PDF:
pdf("argument_x" = "InsectSpraysBoxplot.pdf", width = 8, height = 5)
To increase the size of axis numbers:
plot(dist ~ speed, data = cars, "argument_x" = 1.1)
To specify the line types in a legend:
legend("top", legend=c("Tesla", "Facebook"), col=c("#cc33ff", "#0000ff"), "argument_x"=1:2)
To set the color of a line in abline():
abline(lm(dist ~ speed, data = cars), "argument_x" = "red")
To position a legend in a specific location:
"argument_x"("top", legend=c("Tesla", "Facebook"), col=c("#cc33ff", "#0000ff"), lty=1:2)
To set the plot character/symbol type:
plot(dist ~ speed, data = cars, "argument_x" = 21)
To assign names to colors in the rgb() function:
c1 <- rgb(173,216,230,max = 255, alpha = 100, "argument_x" = "lt.blue")
To specify the label for the x-axis:
plot(dist ~ speed, data = cars, "argument_x" = "Speed (mph)")
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")
To set the title of a legend:
legend("topright", legend = course, fill = c("blue", "green", "yellow", "red"), "argument_x" = "Course")
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
- "col"
- "main"
- "h"
- "fill"
- "cex"
- "dev.off"
- "bg"
- "lwd"
- "legend"
- "bty"
- "type"
- "cex"
- "sub"
- "alpha"
- "pie"
- "breaks"
- "cex.lab"
- "abline"
- "lty"
- "col"
- "ylim"
- "col"
- "cex.main"
- "max"
- "add"
- "file"
- "cex.axis"
- "lty"
- "col"
- "legend"
- "pch"
- "names"
- "xlab"
- "lines"
- "title"
- "labels"