Skip to content

Instantly share code, notes, and snippets.

@dgkeyes
Created April 26, 2019 03:27
Show Gist options
  • Save dgkeyes/69d82068dbb7694a2f40094ebd164142 to your computer and use it in GitHub Desktop.
Save dgkeyes/69d82068dbb7694a2f40094ebd164142 to your computer and use it in GitHub Desktop.
color and fill solutions
# `color` and `fill`
Take your graph from above (the one with `geom_col`) and make the inside of each bar a different color.
```{r}
ggplot(data = sleep_by_gender,
mapping = aes(x = gender,
y = avg_sleep,
fill = gender)) +
geom_col()
```
Make your scatterplot from before that shows weight on the x axis and height on the y axis again, but make the dots show up in different colors based on the `phys_active` variable.
```{r}
ggplot(data = nhanes,
mapping = aes(x = weight,
y = height,
color = phys_active)) +
geom_point()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment