Skip to content

Commit c5b54dd

Browse files
committed
got rid of the underscore for aesthetic reasons (function works both with and without the underscore)
1 parent b825999 commit c5b54dd

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

_posts/ggplot2/2019-08-06-geom_density_2d.Rmd renamed to _posts/ggplot2/2019-08-06-geom_density2d.Rmd

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: geom_density_2d | Examples | Plotly
3-
name: geom_density_2d
4-
permalink: ggplot2/geom_density_2d/
5-
description: How to make a density map using geom_density_2d.
2+
title: geom_density2d | Examples | Plotly
3+
name: geom_density2d
4+
permalink: ggplot2/geom_density2d/
5+
description: How to make a density map using geom_density2d.
66
layout: base
7-
thumbnail: thumbnail/geom_density_2d.jpg
7+
thumbnail: thumbnail/geom_density2d.jpg
88
language: ggplot2
99
page_type: example_index
1010
has_thumbnail: true
@@ -46,15 +46,15 @@ library(plotly)
4646
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
4747
4848
p <- ggplot(beers, aes(x=abv, y=ibu)) +
49-
geom_density_2d() +
49+
geom_density2d() +
5050
labs(y = "bitterness (IBU)",
5151
x = "alcohol volume (ABV)",
5252
title = "Craft beers from American breweries")
5353
ggplotly(p)
5454
5555
# Create a shareable link to your chart
5656
# Set up API credentials: https://plot.ly/r/getting-started
57-
chart_link = api_create(p, filename="geom_density_2d/basic-graph")
57+
chart_link = api_create(p, filename="geom_density2d/basic-graph")
5858
chart_link
5959
```
6060

@@ -70,15 +70,15 @@ library(plotly)
7070
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
7171
7272
p <- ggplot(beers, aes(x=abv, y=ibu)) +
73-
stat_density_2d(aes(fill = stat(level)), geom="polygon") +
73+
stat_density2d(aes(fill = stat(level)), geom="polygon") +
7474
labs(y = "bitterness (IBU)",
7575
x = "alcohol volume (ABV)",
7676
title = "Craft beers from American breweries")
7777
ggplotly(p)
7878
7979
# Create a shareable link to your chart
8080
# Set up API credentials: https://plot.ly/r/getting-started
81-
chart_link = api_create(p, filename="geom_density_2d/filled")
81+
chart_link = api_create(p, filename="geom_density2d/filled")
8282
chart_link
8383
```
8484

@@ -94,7 +94,7 @@ library(plotly)
9494
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
9595
9696
p <- ggplot(beers, aes(x=abv, y=ibu)) +
97-
stat_density_2d(aes(fill = stat(level)), geom="polygon") +
97+
stat_density2d(aes(fill = stat(level)), geom="polygon") +
9898
scale_fill_viridis_c(option = "plasma") +
9999
theme(legend.position = "magma") +
100100
labs(y = "bitterness (IBU)",
@@ -104,7 +104,7 @@ ggplotly(p)
104104
105105
# Create a shareable link to your chart
106106
# Set up API credentials: https://plot.ly/r/getting-started
107-
chart_link = api_create(p, filename="geom_density_2d/preset-colours")
107+
chart_link = api_create(p, filename="geom_density2d/preset-colours")
108108
chart_link
109109
```
110110

@@ -119,7 +119,7 @@ library(plotly)
119119
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
120120
121121
p <- ggplot(beers, aes(x=abv, y=ibu)) +
122-
stat_density_2d(aes(fill = stat(level)), geom="polygon") +
122+
stat_density2d(aes(fill = stat(level)), geom="polygon") +
123123
scale_fill_gradient(low = "lightskyblue1", high = "darkred") +
124124
theme(legend.position = "none") +
125125
labs(y = "bitterness (IBU)",
@@ -129,7 +129,7 @@ ggplotly(p)
129129
130130
# Create a shareable link to your chart
131131
# Set up API credentials: https://plot.ly/r/getting-started
132-
chart_link = api_create(p, filename="geom_density_2d/customized-colours")
132+
chart_link = api_create(p, filename="geom_density2d/customized-colours")
133133
chart_link
134134
```
135135

@@ -146,7 +146,7 @@ library(dplyr)
146146
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
147147
148148
p <- ggplot(beers, aes(x=abv, y=ibu)) +
149-
geom_density_2d(alpha=0.5) +
149+
geom_density2d(alpha=0.5) +
150150
geom_point(data=filter(beers, !is.na(style2)), aes(colour=style2, text = label), alpha=0.3) +
151151
labs(y = "bitterness (IBU)",
152152
x = "alcohol volume (ABV)",
@@ -156,7 +156,7 @@ ggplotly(p)
156156
157157
# Create a shareable link to your chart
158158
# Set up API credentials: https://plot.ly/r/getting-started
159-
chart_link = api_create(p, filename="geom_density_2d/overlaid-points")
159+
chart_link = api_create(p, filename="geom_density2d/overlaid-points")
160160
chart_link
161161
```
162162

_posts/ggplot2/2019-08-06-geom_density_2d.md renamed to _posts/ggplot2/2019-08-06-geom_density2d.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: geom_density_2d | Examples | Plotly
3-
name: geom_density_2d
4-
permalink: ggplot2/geom_density_2d/
5-
description: How to make a density map using geom_density_2d.
2+
title: geom_density2d | Examples | Plotly
3+
name: geom_density2d
4+
permalink: ggplot2/geom_density2d/
5+
description: How to make a density map using geom_density2d.
66
layout: base
7-
thumbnail: thumbnail/geom_density_2d.jpg
7+
thumbnail: thumbnail/geom_density2d.jpg
88
language: ggplot2
99
page_type: example_index
1010
has_thumbnail: true
@@ -48,19 +48,19 @@ library(plotly)
4848
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
4949

5050
p <- ggplot(beers, aes(x=abv, y=ibu)) +
51-
geom_density_2d() +
51+
geom_density2d() +
5252
labs(y = "bitterness (IBU)",
5353
x = "alcohol volume (ABV)",
5454
title = "Craft beers from American breweries")
5555
ggplotly(p)
5656

5757
# Create a shareable link to your chart
5858
# Set up API credentials: https://plot.ly/r/getting-started
59-
chart_link = api_create(p, filename="geom_density_2d/basic-graph")
59+
chart_link = api_create(p, filename="geom_density2d/basic-graph")
6060
chart_link
6161
```
6262

63-
<iframe src="https://plot.ly/~RPlotBot/5808.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
63+
<iframe src="https://plot.ly/~RPlotBot/5855.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
6464

6565
### Filled
6666
Since each of the lines (in the above graph) shows a different "level", setting "fill = stat(level)" allows for a filled graph.
@@ -71,29 +71,30 @@ library(plotly)
7171
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
7272

7373
p <- ggplot(beers, aes(x=abv, y=ibu)) +
74-
stat_density_2d(aes(fill = stat(level)), geom="polygon") +
74+
stat_density2d(aes(fill = stat(level)), geom="polygon") +
7575
labs(y = "bitterness (IBU)",
7676
x = "alcohol volume (ABV)",
7777
title = "Craft beers from American breweries")
7878
ggplotly(p)
7979

8080
# Create a shareable link to your chart
8181
# Set up API credentials: https://plot.ly/r/getting-started
82-
chart_link = api_create(p, filename="geom_density_2d/filled")
82+
chart_link = api_create(p, filename="geom_density2d/filled")
8383
chart_link
8484
```
8585

86-
<iframe src="https://plot.ly/~RPlotBot/5810.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
86+
<iframe src="https://plot.ly/~RPlotBot/5857.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
8787

8888
### Preset Colourscale
8989
["Viridis" colourscales](https://ggplot2.tidyverse.org/reference/scale_viridis.html) are designed to still be perceptible in black-and-white, as well as for those with colourblindness. It comes with five colourscales, selected using the option= parameter: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C"), "viridis" (or "D", the default), and "cividis" (or "E").
9090

91+
9192
```r
9293
library(plotly)
9394
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
9495

9596
p <- ggplot(beers, aes(x=abv, y=ibu)) +
96-
stat_density_2d(aes(fill = stat(level)), geom="polygon") +
97+
stat_density2d(aes(fill = stat(level)), geom="polygon") +
9798
scale_fill_viridis_c(option = "plasma") +
9899
theme(legend.position = "magma") +
99100
labs(y = "bitterness (IBU)",
@@ -103,11 +104,11 @@ ggplotly(p)
103104

104105
# Create a shareable link to your chart
105106
# Set up API credentials: https://plot.ly/r/getting-started
106-
chart_link = api_create(p, filename="geom_density_2d/preset-colours")
107+
chart_link = api_create(p, filename="geom_density2d/preset-colours")
107108
chart_link
108109
```
109110

110-
<iframe src="https://plot.ly/~RPlotBot/5812.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
111+
<iframe src="https://plot.ly/~RPlotBot/5859.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
111112

112113
### Customized Colourscale
113114
You can also set your own colour gradients by defining a high and low point.
@@ -117,7 +118,7 @@ library(plotly)
117118
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
118119

119120
p <- ggplot(beers, aes(x=abv, y=ibu)) +
120-
stat_density_2d(aes(fill = stat(level)), geom="polygon") +
121+
stat_density2d(aes(fill = stat(level)), geom="polygon") +
121122
scale_fill_gradient(low = "lightskyblue1", high = "darkred") +
122123
theme(legend.position = "none") +
123124
labs(y = "bitterness (IBU)",
@@ -127,11 +128,11 @@ ggplotly(p)
127128

128129
# Create a shareable link to your chart
129130
# Set up API credentials: https://plot.ly/r/getting-started
130-
chart_link = api_create(p, filename="geom_density_2d/customized-colours")
131+
chart_link = api_create(p, filename="geom_density2d/customized-colours")
131132
chart_link
132133
```
133134

134-
<iframe src="https://plot.ly/~RPlotBot/5814.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
135+
<iframe src="https://plot.ly/~RPlotBot/5861.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
135136

136137
### Overlaid Points
137138
I use variable "style2" to filter out the six most common beer styles. This way, we can see that the cluster of beers in the top right (i.e. more bitter and higher alcohol content) are IPAs - perhaps unsurprisingly.
@@ -143,7 +144,7 @@ library(dplyr)
143144
beers <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/beers.csv", stringsAsFactors = FALSE)
144145

145146
p <- ggplot(beers, aes(x=abv, y=ibu)) +
146-
geom_density_2d(alpha=0.5) +
147+
geom_density2d(alpha=0.5) +
147148
geom_point(data=filter(beers, !is.na(style2)), aes(colour=style2, text = label), alpha=0.3) +
148149
labs(y = "bitterness (IBU)",
149150
x = "alcohol volume (ABV)",
@@ -153,9 +154,9 @@ ggplotly(p)
153154

154155
# Create a shareable link to your chart
155156
# Set up API credentials: https://plot.ly/r/getting-started
156-
chart_link = api_create(p, filename="geom_density_2d/overlaid-points")
157+
chart_link = api_create(p, filename="geom_density2d/overlaid-points")
157158
chart_link
158159
```
159160

160-
<iframe src="https://plot.ly/~RPlotBot/5816.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
161+
<iframe src="https://plot.ly/~RPlotBot/5863.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
161162

0 commit comments

Comments
 (0)