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

Skip to content

Commit a915870

Browse files
Joseph Damibanicolaskruchten
Joseph Damiba
authored andcommitted
Revert "remove ggplot2 posts as they are being copied into r.docs repo"
This reverts commit 71e83cc.
1 parent 82306db commit a915870

File tree

85 files changed

+14910
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+14910
-0
lines changed

_posts/ggplot2/2011-11-29-scale-x.Rmd

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
name: scale_x_date
3+
permalink: ggplot2/scale-x/
4+
redirect_from: ggplot2/scale_x_date/
5+
description: How to make plots in R and ggplot2 using scale_x_date.
6+
layout: base
7+
thumbnail: thumbnail/time-series.jpg
8+
language: ggplot2
9+
page_type: example_index
10+
display_as: layout_opt
11+
output:
12+
html_document:
13+
keep_md: true
14+
---
15+
16+
```{r, echo = FALSE, message=FALSE}
17+
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
18+
Sys.setenv("plotly_username"="bdun9")
19+
Sys.setenv("plotly_api_key"="ukqr128tmk")
20+
```
21+
22+
### New to Plotly?
23+
24+
Plotly's R library is free and open source!<br>
25+
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
26+
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
27+
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
28+
29+
### Version Check
30+
31+
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
32+
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
33+
34+
```{r}
35+
library(plotly)
36+
packageVersion('plotly')
37+
```
38+
39+
## By Month
40+
41+
```{r, results='hide'}
42+
library(plotly)
43+
library(scales)
44+
45+
x <- c("04-01-10","05-01-10","06-01-10","07-01-10","08-01-10","09-01-10","10-01-10","11-01-10","12-01-10","01-01-11","02-01-11","03-01-11","04-01-11","05-01-11","06-01-11","07-01-11","08-01-11","09-01-11","10-01-11","11-01-11","12-01-11","01-01-12","02-01-12","03-01-12","04-01-12","05-01-12","06-01-12")
46+
y <- c(120,210,130,160,190,210,80,70,110,120,140,160,130,200,110,180,210,200,90,60,100,100,120,170,100,180,120)
47+
48+
MySample <- data.frame(x) ## convert to dataframe
49+
MySample$y <- y
50+
51+
# install.packages("lubridate")
52+
require(lubridate)
53+
54+
MySample$date <- as.Date(MySample$x, "%m-%d-%y")
55+
MySample$year <- year(MySample$date)
56+
57+
p <- ggplot(MySample, aes(date, y, fill = year)) +
58+
geom_bar(stat="identity") +
59+
facet_grid(. ~ year, scales = "free") +
60+
scale_x_date(labels = date_format("%b/%y")) +
61+
scale_fill_gradient(breaks=unique(MySample$year))
62+
63+
p <- ggplotly(p)
64+
65+
# Create a shareable link to your chart
66+
# Set up API credentials: https://plot.ly/r/getting-started
67+
chart_link = api_create(p, filename="scalex/month")
68+
chart_link
69+
```
70+
71+
``` {r, echo=FALSE}
72+
chart_link
73+
```
74+
Inspired by <a href="http://stackoverflow.com/questions/11472856/month-year-bar-graph-plot-faceted-and-filled-on-year-with-data-input-as-date-in?rq=1">Stack Overflow</a>.
75+
76+
## By Year
77+
78+
```{r, results='hide'}
79+
library(plotly)
80+
library(scales)
81+
82+
set.seed(12345)
83+
Date <- seq(as.Date("2010/1/1"), as.Date("2014/1/1"), "week")
84+
Y <- rnorm(n=length(Date), mean=100, sd=1)
85+
df <- data.frame(Date, Y)
86+
87+
df$Year <- format(df$Date, "%Y")
88+
df$Month <- format(df$Date, "%b")
89+
df$Day <- format(df$Date, "%d")
90+
91+
df$MonthDay <- format(df$Date, "%d-%b")
92+
93+
df$CommonDate <- as.Date(paste0("2000-",format(df$Date, "%j")), "%Y-%j")
94+
95+
p <- ggplot(data = df,
96+
mapping = aes(x = CommonDate, y = Y, shape = Year, colour = Year)) +
97+
geom_point() +
98+
geom_line() +
99+
facet_grid(facets = Year ~ .) +
100+
scale_x_date(labels = function(x) format(x, "%d-%b"))
101+
102+
p <- ggplotly(p)
103+
104+
# Create a shareable link to your chart
105+
# Set up API credentials: https://plot.ly/r/getting-started
106+
chart_link = api_create(p, filename="scalex/year")
107+
chart_link
108+
```
109+
110+
``` {r, echo=FALSE}
111+
chart_link
112+
```
113+
Inspired by <a href="http://stackoverflow.com/questions/11472856/month-year-bar-graph-plot-faceted-and-filled-on-year-with-data-input-as-date-in?rq=1">Stack Overflow</a>.
114+
115+

_posts/ggplot2/2011-11-29-scale-x.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
name: scale_x_date
3+
permalink: ggplot2/scale-x/
4+
redirect_from: ggplot2/scale_x_date/
5+
description: How to make plots in R and ggplot2 using scale_x_date.
6+
layout: base
7+
thumbnail: thumbnail/time-series.jpg
8+
language: ggplot2
9+
page_type: example_index
10+
display_as: layout_opt
11+
output:
12+
html_document:
13+
keep_md: true
14+
---
15+
16+
17+
18+
### New to Plotly?
19+
20+
Plotly's R library is free and open source!<br>
21+
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
22+
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
23+
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
24+
25+
### Version Check
26+
27+
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
28+
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
29+
30+
31+
```r
32+
library(plotly)
33+
packageVersion('plotly')
34+
```
35+
36+
```
37+
## [1] '4.8.0'
38+
```
39+
40+
## By Month
41+
42+
43+
```r
44+
library(plotly)
45+
library(scales)
46+
47+
x <- c("04-01-10","05-01-10","06-01-10","07-01-10","08-01-10","09-01-10","10-01-10","11-01-10","12-01-10","01-01-11","02-01-11","03-01-11","04-01-11","05-01-11","06-01-11","07-01-11","08-01-11","09-01-11","10-01-11","11-01-11","12-01-11","01-01-12","02-01-12","03-01-12","04-01-12","05-01-12","06-01-12")
48+
y <- c(120,210,130,160,190,210,80,70,110,120,140,160,130,200,110,180,210,200,90,60,100,100,120,170,100,180,120)
49+
50+
MySample <- data.frame(x) ## convert to dataframe
51+
MySample$y <- y
52+
53+
# install.packages("lubridate")
54+
require(lubridate)
55+
56+
MySample$date <- as.Date(MySample$x, "%m-%d-%y")
57+
MySample$year <- year(MySample$date)
58+
59+
p <- ggplot(MySample, aes(date, y, fill = year)) +
60+
geom_bar(stat="identity") +
61+
facet_grid(. ~ year, scales = "free") +
62+
scale_x_date(labels = date_format("%b/%y")) +
63+
scale_fill_gradient(breaks=unique(MySample$year))
64+
65+
p <- ggplotly(p)
66+
67+
# Create a shareable link to your chart
68+
# Set up API credentials: https://plot.ly/r/getting-started
69+
chart_link = api_create(p, filename="scalex/month")
70+
chart_link
71+
```
72+
73+
<iframe src="https://plot.ly/~bdun9/3363.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
74+
Inspired by <a href="http://stackoverflow.com/questions/11472856/month-year-bar-graph-plot-faceted-and-filled-on-year-with-data-input-as-date-in?rq=1">Stack Overflow</a>.
75+
76+
## By Year
77+
78+
79+
```r
80+
library(plotly)
81+
library(scales)
82+
83+
set.seed(12345)
84+
Date <- seq(as.Date("2010/1/1"), as.Date("2014/1/1"), "week")
85+
Y <- rnorm(n=length(Date), mean=100, sd=1)
86+
df <- data.frame(Date, Y)
87+
88+
df$Year <- format(df$Date, "%Y")
89+
df$Month <- format(df$Date, "%b")
90+
df$Day <- format(df$Date, "%d")
91+
92+
df$MonthDay <- format(df$Date, "%d-%b")
93+
94+
df$CommonDate <- as.Date(paste0("2000-",format(df$Date, "%j")), "%Y-%j")
95+
96+
p <- ggplot(data = df,
97+
mapping = aes(x = CommonDate, y = Y, shape = Year, colour = Year)) +
98+
geom_point() +
99+
geom_line() +
100+
facet_grid(facets = Year ~ .) +
101+
scale_x_date(labels = function(x) format(x, "%d-%b"))
102+
103+
p <- ggplotly(p)
104+
105+
# Create a shareable link to your chart
106+
# Set up API credentials: https://plot.ly/r/getting-started
107+
chart_link = api_create(p, filename="scalex/year")
108+
chart_link
109+
```
110+
111+
<iframe src="https://plot.ly/~bdun9/727.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
112+
Inspired by <a href="http://stackoverflow.com/questions/11472856/month-year-bar-graph-plot-faceted-and-filled-on-year-with-data-input-as-date-in?rq=1">Stack Overflow</a>.
113+
114+

_posts/ggplot2/2011-11-29-scale-y.Rmd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: scale_y_continuous
3+
permalink: ggplot2/scale-y/
4+
redirect_from: ggplot2/scale_y_continuous/
5+
description: How to use logarithmic scales with ggplot2 axes.
6+
layout: base
7+
thumbnail: thumbnail/log.jpg
8+
language: ggplot2
9+
page_type: example_index
10+
display_as: layout_opt
11+
output:
12+
html_document:
13+
keep_md: true
14+
---
15+
16+
```{r, echo = FALSE, message=FALSE}
17+
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
18+
Sys.setenv("plotly_username"="RPlotBot")
19+
Sys.setenv("plotly_api_key"="q0lz6r5efr")
20+
```
21+
22+
### New to Plotly?
23+
24+
Plotly's R library is free and open source!<br>
25+
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
26+
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
27+
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
28+
29+
### Version Check
30+
31+
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
32+
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
33+
34+
```{r}
35+
library(plotly)
36+
packageVersion('plotly')
37+
```
38+
39+
## Basic
40+
41+
```{r, results='hide'}
42+
library(plotly)
43+
44+
p <- ggplot(diamonds, aes(color, log10(price))) +
45+
geom_boxplot() +
46+
scale_y_continuous("Price, log10-scaling")
47+
48+
p <- ggplotly(p)
49+
50+
# Create a shareable link to your chart
51+
# Set up API credentials: https://plot.ly/r/getting-started
52+
chart_link = plotly_POST(p, filename="scaley/basic")
53+
chart_link
54+
```
55+
56+
``` {r, echo=FALSE}
57+
chart_link
58+
```
59+
Inspired by <a href="http://stackoverflow.com/questions/4699493/transform-only-one-axis-to-log10-scale-with-ggplot2">Stack Overflow</a>.

_posts/ggplot2/2011-11-29-scale-y.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: scale_y_continuous
3+
permalink: ggplot2/scale-y/
4+
redirect_from: ggplot2/scale_y_continuous/
5+
description: How to use logarithmic scales with ggplot2 axes.
6+
layout: base
7+
thumbnail: thumbnail/log.jpg
8+
language: ggplot2
9+
page_type: example_index
10+
display_as: layout_opt
11+
output:
12+
html_document:
13+
keep_md: true
14+
---
15+
16+
17+
18+
### New to Plotly?
19+
20+
Plotly's R library is free and open source!<br>
21+
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
22+
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
23+
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
24+
25+
### Version Check
26+
27+
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
28+
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
29+
30+
31+
```r
32+
library(plotly)
33+
packageVersion('plotly')
34+
```
35+
36+
```
37+
## [1] '4.5.6.9000'
38+
```
39+
40+
## Basic
41+
42+
43+
```r
44+
library(plotly)
45+
46+
p <- ggplot(diamonds, aes(color, log10(price))) +
47+
geom_boxplot() +
48+
scale_y_continuous("Price, log10-scaling")
49+
50+
p <- ggplotly(p)
51+
52+
# Create a shareable link to your chart
53+
# Set up API credentials: https://plot.ly/r/getting-started
54+
chart_link = plotly_POST(p, filename="scaley/basic")
55+
chart_link
56+
```
57+
58+
<iframe src="https://plot.ly/~RPlotBot/4198.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
59+
Inspired by <a href="http://stackoverflow.com/questions/4699493/transform-only-one-axis-to-log10-scale-with-ggplot2">Stack Overflow</a>.

0 commit comments

Comments
 (0)