Data visualization Flashcards
(8 cards)
Which library is critical for creating visualizations such as scatterplots in R?
ggplot2
What is the recipe to create a scatterplot?
ggplot(…) + geom_point()
Ex: ggplot(my_tibble, aes(x = gdpPerCap, y = lifeExp)) + geom_point()
What are the three parts of a ggplot graph?
- The data that we’re visualizing.
Ex: ggplot(my_tibble… - The mapping of variables in your dataset to aesthetics in your graph.
Ex: …aes(x = gdpPerCap, y = lifeExp))… - Specifying the type of graph you’re creating.
Ex: … + geom_point()
What is an aesthetic?
A visual dimension of a graph that can be used to communicate information.
How can you make a scatter plot logarithmic?
scale_x_log10() or scale_y_log10()
Ex: ggplot(my_tibble, aes(x = gdpPerCap, y = lifeExp)) + geom_point() +
scale_x_log10()
What aesthetic options are available in scatter plots?
x, y, color, size
Ex: aes(x = thing1, y = thing2, color = thing3, size = thing4)
What is faceting?
Splitting one graph into many graphs based on a categorical variable.
What is the function to facet a graph based on a certain variable?
facet_wrap()
Ex: … geom_point() +
facet_wrap(~ continent)