Skip to content

Commit

Permalink
add ggplot2 colors
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed Jul 28, 2019
1 parent 7c37385 commit bcdb7f8
Show file tree
Hide file tree
Showing 77 changed files with 3,244 additions and 468 deletions.
458 changes: 0 additions & 458 deletions 0_templateChartPage.html

This file was deleted.

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 removed 0_templateChartPage_files/tmp
Empty file.
6 changes: 6 additions & 0 deletions 221-continuous-color-palette-with-ggplot2.html
@@ -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>
6 changes: 6 additions & 0 deletions 222-discrete-color-palette-ggplot2.html
@@ -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>
117 changes: 117 additions & 0 deletions 241-custom-layout-strip-ggplot2.Rmd
@@ -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")
```

0 comments on commit bcdb7f8

Please sign in to comment.