0
0
R Programmingprogramming~10 mins

Themes and theme customization in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to apply a minimal theme to a ggplot.

R Programming
library(ggplot2)
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + [1]()
Drag options to blanks, or click blank then click option'
Atheme_classic
Btheme_minimal
Ctheme_dark
Dtheme_bw
Attempts:
3 left
💡 Hint
Common Mistakes
Using a theme function that changes the plot style but is not minimal.
Forgetting the parentheses after the theme function.
2fill in blank
medium

Complete the code to change the base font size of a ggplot theme to 16.

R Programming
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + theme_minimal(base_size = [1])
Drag options to blanks, or click blank then click option'
A16
B10
C12
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using a smaller font size like 10 or 12 when the goal is to increase size.
Forgetting to assign the value to base_size.
3fill in blank
hard

Fix the error in the code to set the plot background color to light blue.

R Programming
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + theme(plot.background = element_rect(fill = [1]))
Drag options to blanks, or click blank then click option'
Alight blue
Bblue light
C#lightblue
Dlightblue
Attempts:
3 left
💡 Hint
Common Mistakes
Using color names with spaces like 'light blue'.
Adding '#' before color names that are not hex codes.
4fill in blank
hard

Fill both blanks to customize axis text color and size.

R Programming
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + theme(axis.text.x = element_text(color = [1], size = [2]))
Drag options to blanks, or click blank then click option'
A"red"
B14
C12
D"blue"
Attempts:
3 left
💡 Hint
Common Mistakes
Using color without quotes.
Choosing a smaller size when the goal is to increase text size.
5fill in blank
hard

Fill all three blanks to create a custom theme with green panel background, no grid lines, and bold axis titles.

R Programming
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + theme(panel.background = element_rect(fill = [1]), panel.grid.major = [2], axis.title = element_text(face = [3]))
Drag options to blanks, or click blank then click option'
A"green"
Belement_blank()
C"bold"
D"italic"
Attempts:
3 left
💡 Hint
Common Mistakes
Using color names without quotes.
Using incorrect functions to remove grid lines.
Using 'italic' instead of 'bold' for axis titles.