Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e83b9b8

Browse files
committed
should be final commit!
1 parent 93f57b9 commit e83b9b8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

_posts/ggplot2/2019-08-02-geom_violin.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Source: [Dave Wassermann and Ally Flinn](https://docs.google.com/spreadsheets/d/
4646
```{r, results='hide'}
4747
library(plotly)
4848
district_density <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/district_density.csv", stringsAsFactors = FALSE)
49-
49+
district_density$cluster <- factor(district_density$cluster, levels=c("Pure urban", "Urban-suburban mix", "Dense suburban", "Sparse suburban", "Rural-suburban mix", "Pure rural"))
5050
# MAKE THIS A FACTOR, AND ALSO ADD A THUMBNAIL
5151
5252
p <- ggplot(district_density,aes(x=cluster, y=dem_margin, fill=cluster)) +
@@ -68,7 +68,7 @@ chart_link
6868
```
6969

7070
### Flipping the Axes
71-
With geom_violin(), the y-axis must always be the continuous variable, and the x-axis the ctegorical variable. To create horizontal violin graphs, add coord_flip() without changing .
71+
With geom\_violin(), the y-axis must always be the continuous variable, and the x-axis the categorical variable. To create horizontal violin graphs, keep the x- and y-variables as is and add coord\_flip().
7272

7373
```{r, results='hide'}
7474
library(plotly)
@@ -119,7 +119,7 @@ chart_link
119119
```
120120

121121
### Customized Appearance
122-
Add colour to the facet titles, centre-align the itle, rotate the y-axis title, change the font, and get rid of the unnecessary legend. Note that coord_flip() flips the axes for the variables and the titles, but does not flip theme() elements.
122+
Add colour to the facet titles, centre-align the title, rotate the y-axis title, change the font, and get rid of the unnecessary legend. Note that coord_flip() flips the axes for the variables and the titles, but does not flip theme() elements.
123123

124124
```{r, results='hide'}
125125
library(plotly)
@@ -150,7 +150,7 @@ chart_link
150150
```
151151

152152
### Rotated Axis Text
153-
Rotated the x-axis text 45 degrees, and used facet_grid to create a 4x4 facet (compared to facet_wrap, which defaults to 2x2).
153+
Rotated the x-axis text 45 degrees, and used facet\_grid to create a 4x1 facet (compared to facet\_wrap, which defaults to 2x2).
154154

155155
```{r, results='hide'}
156156
library(plotly)

_posts/ggplot2/2019-08-02-geom_violin.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Source: [Dave Wassermann and Ally Flinn](https://docs.google.com/spreadsheets/d/
4848
```r
4949
library(plotly)
5050
district_density <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/district_density.csv", stringsAsFactors = FALSE)
51+
district_density$cluster <- factor(district_density$cluster, levels=c("Pure urban", "Urban-suburban mix", "Dense suburban", "Sparse suburban", "Rural-suburban mix", "Pure rural"))
52+
# MAKE THIS A FACTOR, AND ALSO ADD A THUMBNAIL
5153

5254
p <- ggplot(district_density,aes(x=cluster, y=dem_margin, fill=cluster)) +
5355
geom_violin(colour=NA) +
@@ -66,7 +68,7 @@ chart_link
6668
<iframe src="https://plot.ly/~RPlotBot/5785.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
6769

6870
### Flipping the Axes
69-
With geom_violin(), the y-axis must always be the continuous variable, and the x-axis the ctegorical variable. To create horizontal violin graphs, add coord_flip() without changing .
71+
With geom\_violin(), the y-axis must always be the continuous variable, and the x-axis the categorical variable. To create horizontal violin graphs, keep the x- and y-variables as is and add coord\_flip().
7072

7173

7274
```r
@@ -115,7 +117,7 @@ chart_link
115117
<iframe src="https://plot.ly/~RPlotBot/5789.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
116118

117119
### Customized Appearance
118-
Add colour to the facet titles, centre-align the itle, rotate the y-axis title, change the font, and get rid of the unnecessary legend. Note that coord_flip() flips the axes for the variables and the titles, but does not flip theme() elements.
120+
Add colour to the facet titles, centre-align the title, rotate the y-axis title, change the font, and get rid of the unnecessary legend. Note that coord_flip() flips the axes for the variables and the titles, but does not flip theme() elements.
119121

120122

121123
```r
@@ -145,7 +147,7 @@ chart_link
145147
<iframe src="https://plot.ly/~RPlotBot/5791.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
146148

147149
### Rotated Axis Text
148-
Rotated the x-axis text 45 degrees, and used facet_grid to create a 4x4 facet (compared to facet_wrap, which defaults to 2x2).
150+
Rotated the x-axis text 45 degrees, and used facet\_grid to create a 4x1 facet (compared to facet\_wrap, which defaults to 2x2).
149151

150152

151153
```r

0 commit comments

Comments
 (0)