https://github.com/datacamp/ggdc
Datacamp Themes for ggplot2.
https://github.com/datacamp/ggdc
Last synced: 3 months ago
JSON representation
Datacamp Themes for ggplot2.
- Host: GitHub
- URL: https://github.com/datacamp/ggdc
- Owner: datacamp
- License: mit
- Created: 2017-12-28T22:58:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-18T20:00:43.000Z (over 4 years ago)
- Last Synced: 2025-06-06T02:03:36.782Z (about 1 year ago)
- Language: R
- Size: 12.4 MB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- awesome-ggplot2 - ggdc
README
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
ggdc:::dc_set_chunk_opts()
library(dplyr)
library(ggplot2)
```
# ggdc
The goal of ggdc is to provides Datacamp themes for ggplot2, rstudio, and other
document formats.
## Installation
You can install the package from github using `devtools`.
``` r
devtools::install_github("datacamp/ggdc")
```
## Plotting Theme
`ggdc` supports two variants of the datacamp theme (light and dark).
## Light Theme
```{r example_1}
library(ggdc)
p <- diamonds %>%
ggplot(aes(x = carat, y = price, color = cut)) +
geom_point(alpha = 0.6) +
labs(
title = "Price vs. Carat",
subtitle = 'Weightier diamonds are more expensive',
caption = 'Source: Diamonds dataset'
) +
scale_color_datacamp(palette = 'accents_light')
p +
theme_datacamp_light()
```
### Dark Theme
```{r dark-theme}
p +
theme_datacamp_dark()
```
### Logo
You can add a logo to the plot using `finalize_plot`. You can make this the default for all plots in an Rmd by adding `dc_set_chunk_opts(finalize_plot = TRUE)` in the setup chunk.
```{r}
finalize_plot(p + theme_datacamp_dark())
```
### Facets
```{r example-facets}
diamonds %>%
ggplot(aes(x = price)) +
geom_histogram() +
facet_wrap(~ cut, scales = 'free_y') +
labs(
title = 'Histogram of Diamonds Prices',
caption = 'Source: ggplot2'
) +
theme_datacamp_light() +
scale_fill_datacamp()
```
## Rstudio Theme
`ggdc` also ships with a syntax highlighting theme for RStudio. You can install
it by running
```r
install_rstheme()
```