plot()
In this page:
plot()
plot(x, y) is R's general-purpose base plotting function, drawing a scatter plot by default from two numeric vectors. Judge0 (and other non-interactive environments) capture plot output as a saved image rather than displaying a window. plot() accepts many arguments (type, col, pch, etc.) to customize its appearance.
Note: type = "l" draws a line plot instead of scattered points; type = "b" draws both points and connecting lines.
Example: plot()
x <- 1:10
y <- x^2
# In a graphical R environment this renders a plot window / image file.
# Here we just confirm the data plot() would use is correct:
cat("x values:", x, "\n")
cat("y values:", y, "\n")
cat("plot(x, y) would draw a scatter plot of y = x^2\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: