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

Skip to content

Commit 1d50e96

Browse files
committed
fixed colorscale (wasn't working, possibly plotly.R code?) + added labels so readers know what they're looking at
1 parent 8489762 commit 1d50e96

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

_posts/ggplot2/2016-11-29-geom_tile.Rmd

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ library(reshape2)
4646
4747
p <- volcano %>%
4848
melt() %>%
49-
ggplot(aes(Var1, Var2, fill = value)) + geom_tile()
49+
ggplot(aes(Var1, Var2, fill = value)) + geom_tile() +
50+
labs(x = "West to East",
51+
y="North to South",
52+
title = "Visualizing the Topography of Maunga Whau")
5053
5154
p <- ggplotly(p)
5255
@@ -97,20 +100,19 @@ chart_link
97100
```
98101
Inspired by <a href="http://stackoverflow.com/questions/25528059/cluster-data-in-heat-map-in-r-ggplot">Stack Overflow</a>
99102

100-
### Continuous Colorscale
103+
### Modified Colorscale
101104

102105
```{r, results='hide'}
103106
library(plotly)
104107
library(reshape2)
105108
106109
p <- volcano %>%
107110
melt() %>%
108-
ggplot(aes(Var1, Var2, fill = value)) + geom_tile()
109-
110-
p <- plotly_build(p)
111-
112-
# Modify the plotly abject to add colorscale
113-
p$data[[1]]$colorscale = list(c(0, "#ffe6cc"), c(1, "#ff8400"))
111+
ggplot(aes(Var1, Var2, fill = value)) + geom_tile() +
112+
scale_fill_gradient(low="#ffe6cc", high="#ff8400") +
113+
labs(x = "West to East",
114+
y="North to South",
115+
title = "Visualizing the Topography of Maunga Whau")
114116
115117
p <- ggplotly(p)
116118

_posts/ggplot2/2016-11-29-geom_tile.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ packageVersion('plotly')
3636
```
3737

3838
```
39-
## [1] '4.5.6.9000'
39+
## [1] '4.9.0'
4040
```
4141

4242
### Matrix
@@ -48,7 +48,10 @@ library(reshape2)
4848

4949
p <- volcano %>%
5050
melt() %>%
51-
ggplot(aes(Var1, Var2, fill = value)) + geom_tile()
51+
ggplot(aes(Var1, Var2, fill = value)) + geom_tile() +
52+
labs(x = "West to East",
53+
y="North to South",
54+
title = "Visualizing the Topography of Maunga Whau")
5255

5356
p <- ggplotly(p)
5457

@@ -96,7 +99,7 @@ chart_link
9699
<iframe src="https://plot.ly/~RPlotBot/4177.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
97100
Inspired by <a href="http://stackoverflow.com/questions/25528059/cluster-data-in-heat-map-in-r-ggplot">Stack Overflow</a>
98101

99-
### Continuous Colorscale
102+
### Modified Colorscale
100103

101104

102105
```r
@@ -105,12 +108,11 @@ library(reshape2)
105108

106109
p <- volcano %>%
107110
melt() %>%
108-
ggplot(aes(Var1, Var2, fill = value)) + geom_tile()
109-
110-
p <- plotly_build(p)
111-
112-
# Modify the plotly abject to add colorscale
113-
p$data[[1]]$colorscale = list(c(0, "#ffe6cc"), c(1, "#ff8400"))
111+
ggplot(aes(Var1, Var2, fill = value)) + geom_tile() +
112+
scale_fill_gradient(low="#ffe6cc", high="#ff8400") +
113+
labs(x = "West to East",
114+
y="North to South",
115+
title = "Visualizing the Topography of Maunga Whau")
114116

115117
p <- ggplotly(p)
116118

0 commit comments

Comments
 (0)