Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
3,244 additions
and
468 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Refresh" content="0; url=https://www.r-graph-gallery.com/ggplot2-color.html" /> | ||
</head> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Refresh" content="0; url=https://www.r-graph-gallery.com/ggplot2-color.html" /> | ||
</head> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
title: "Customize small multiple appearance with ggplot2" | ||
descriptionMeta: "ggplot2 makes it a breeze to build small multiples. This post shows how to customize the layout, notably using the strip options." | ||
descriptionTop: "[ggplot2](ggplot2-package.html) makes it a breeze to build small multiples. This post shows how to customize the layout, notably using the strip options." | ||
sectionText: "ggplot2 Section" | ||
sectionLink: "ggplot2-package.html" | ||
DataToVizText: "About Scatter" | ||
DataToVizLink: "data-to-viz.com/graph/scatter.html" | ||
url: "241-custom-layout-strip-ggplot2" | ||
output: | ||
html_document: | ||
self_contained: false | ||
mathjax: default | ||
lib_dir: libs | ||
template: template_rgg.html | ||
css: style.css | ||
toc: TRUE | ||
toc_float: TRUE | ||
toc_depth: 2 | ||
df_print: "paged" | ||
--- | ||
|
||
|
||
```{r global options, include = FALSE} | ||
knitr::opts_chunk$set( warning=FALSE, message=FALSE) | ||
``` | ||
|
||
<div class="container" style="padding-top: 40px"> | ||
|
||
|
||
|
||
|
||
|
||
|
||
This page aims to provide useful R code to customize the strips of a `ggplot2` plots when using faceting. For other ggplot2 customization, visit the [dedicated page](ggplot2-package.html). | ||
|
||
Here we want to modify non-data components, which is often done trough the `theme()` command. This page is strongly inspired from the help page of ggplot2 (`?theme`). Also, do not hesitate to visit the very strong [ggplot2 documentation](http://docs.ggplot2.org/0.9.3/theme.html) for more information. | ||
|
||
Chart 1 is a really basic plot relying on the `mtcars` dataset. The 3 following charts show how to customize `strip` background, text, and how to modify the space between sections. | ||
|
||
|
||
<div class = "row"> | ||
|
||
<div class = "col-md-6 col-sm-12"> | ||
|
||
```{r thecodeA, echo=FALSE, out.width = "100%", fig.height=7} | ||
library(ggplot2) | ||
# basic chart | ||
basic=ggplot(mtcars, aes(wt, mpg)) + | ||
geom_point() + | ||
facet_wrap(~ cyl) | ||
basic | ||
``` | ||
</div> | ||
|
||
<div class = "col-md-6 col-sm-12"> | ||
|
||
```{r thecodeB, echo=FALSE, out.width = "100%", fig.height=7} | ||
# Change background | ||
basic + theme(strip.background = element_rect(colour = "red", fill = alpha("blue",0.2) )) | ||
``` | ||
</div> | ||
|
||
<div class = "col-md-6 col-sm-12"> | ||
|
||
```{r thecodeC, echo=FALSE, out.width = "100%", fig.height=7} | ||
# Change the text | ||
basic + theme(strip.text.x = element_text(colour = "red", face = "bold", size=10, angle=30)) | ||
``` | ||
</div> | ||
|
||
<div class = "col-md-6 col-sm-12"> | ||
|
||
```{r thecodeD, echo=FALSE, out.width = "100%", fig.height=7} | ||
# Change the space between parts: | ||
basic + theme(panel.spacing = unit(4, "lines")) | ||
``` | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
|
||
```{r thecodeA, eval=FALSE} | ||
``` | ||
|
||
```{r thecodeB, eval=FALSE} | ||
``` | ||
|
||
```{r thecodeC, eval=FALSE} | ||
``` | ||
|
||
```{r thecodeD, eval=FALSE} | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
<!-- Close container --> | ||
</div> | ||
|
||
|
||
|
||
|
||
```{r, echo=FALSE} | ||
htmltools::includeHTML("htmlChunkRelatedCorrelation.html") | ||
``` |
Oops, something went wrong.