8000 the rest of files revised · plotly/plotly.r-docs@bbfc0ee · GitHub
[go: up one dir, main page]

Skip to content

Commit bbfc0ee

Browse files
author
mahdis-z
committed
the rest of files revised
1 parent 77709f2 commit bbfc0ee

File tree

93 files changed

+1325
-1113
lines changed

Some content is hidden

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

93 files changed

+1325
-1113
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ require(lubridate)
3434
MySample$date <- as.Date(MySample$x, "%m-%d-%y")
3535
MySample$year <- year(MySample$date)
3636
37-
p <- ggplot(MySample, aes(date, y, fill = year)) +
37+
fig <- ggplot(MySample, aes(date, y, fill = year)) +
3838
geom_bar(stat="identity") +
3939
facet_grid(. ~ year, scales = "free") +
4040
scale_x_date(labels = date_format("%b/%y")) +
4141
scale_fill_gradient(breaks=unique(MySample$year))
4242
43-
p <- ggplotly(p)
43+
fig <- ggplotly(p)
4444
45-
p
45+
fig
4646
```
4747
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>.
4848

@@ -65,15 +65,15 @@ df$MonthDay <- format(df$Date, "%d-%b")
6565
6666
df$CommonDate <- as.Date(paste0("2000-",format(df$Date, "%j")), "%Y-%j")
6767
68-
p <- ggplot(data = df,
68+
fig <- ggplot(data = df,
6969
mapping = aes(x = CommonDate, y = Y, shape = Year, colour = Year)) +
7070
geom_point() +
7171
geom_line() +
7272
facet_grid(facets = Year ~ .) +
7373
scale_x_date(labels = function(x) format(x, "%d-%b"))
7474
75-
p <- ggplotly(p)
75+
fig <- ggplotly(p)
7676
77-
p
77+
fig
7878
```
7979
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>.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ knitr::opts_chunk$set(message = FALSE, warning=FALSE)
2121
```{r}
2222
library(plotly)
2323
24-
p <- ggplot(diamonds, aes(color, log10(price))) +
24+
fig <- ggplot(diamonds, aes(color, log10(price))) +
2525
geom_boxplot() +
2626
scale_y_continuous("Price, log10-scaling")
2727
28-
p <- ggplotly(p)
28+
fig <- ggplotly(p)
2929
30-
p
30+
fig
3131
```
3232
Inspired by <a href="http://stackoverflow.com/questions/4699493/transform-only-one-axis-to-log10-scale-with-ggplot2">Stack Overflow</a>.

ggplot2/2016-11-29-aes.Rmd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ ds <- data.frame(x = 1:10,
2525
group = LETTERS[1:2])
2626
2727
# Use the fill aesthetic to specify the fill color for the bars
28-
p <- ggplot(ds, aes(x, y)) +
28+
fig <- ggplot(ds, aes(x, y)) +
2929
geom_bar(aes(fill = group), stat = "identity") +
3030
ggtitle("Filled bar chart")
3131
32-
p <- ggplotly(p)
32+
fig <- ggplotly(p)
3333
34-
p
34+
fig
3535
```
3636

3737
### Group
@@ -46,20 +46,20 @@ x3 <- x2 + 100
4646
x <- c(x1, x2, x3)
4747
y <- c(2*x1, 5*x2, -2*x3)
4848
49-
group <- c(rep("A", length(x1)),
49+
groufig <- c(rep("A", length(x1)),
5050
rep("B", length(x2)),
5151
rep("C", length(x3)))
5252
5353
ds <- data.frame(x, y, group)
5454
5555
# Use the group aesthetic to ensure lines are drawn separately for each group
56-
p <- ggplot(ds, aes(x, y)) +
56+
fig <- ggplot(ds, aes(x, y)) +
5757
geom_line(aes(group = group, color = group), size = 2) +
5858
ggtitle("Group specific line chart")
5959
60-
p <- ggplotly(p)
60+
fig <- ggplotly(p)
6161
62-
p
62+
fig
6363
```
6464

6565
### Label
@@ -71,14 +71,14 @@ ds <- data.frame(x = rnorm(10),
7171
y = rnorm(10),
7272
group = LETTERS[1:2])
7373
74-
p <- ggplot(ds, aes(x, y)) +
74+
fig <- ggplot(ds, aes(x, y)) +
7575
geom_point(aes(color = group), size = 7) +
7676
geom_text(aes(label = group), size = 4) +
7777
ggtitle("Annotation with labels")
7878
79-
p <- ggplotly(p)
79+
fig <- ggplotly(p)
8080
81-
p
81+
fig
8282
```
8383

8484
### Shape
@@ -91,14 +91,14 @@ ds <- data.frame(x = letters[1:5],
9191
group = LETTERS[1:4])
9292
9393
# Use aes shape to map individual points and or different groups to different shapes
94-
p <- ggplot(ds, aes(x, y)) +
94+
fig <- ggplot(ds, aes(x, y)) +
9595
geom_point(aes(color = group, shape = group), size = 5) +
9696
geom_line(aes(group = group, linetype = group)) +
9797
ggtitle("Groupwise shapes and line types")
9898
99-
p <- ggplotly(p)
99+
fig <- ggplotly(p)
100100
101-
p
101+
fig
102102
```
103103

104104
Inspired by <a href="http://docs.ggplot2.org/current/">ggplot2 documentation</a>

ggplot2/2016-11-29-axis-text.Rmd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ set.seed(123)
2323
2424
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
2525
26-
p <- ggplot(df, aes(carat, price, color = color, alpha = cut)) +
26+
fig <- ggplot(df, aes(carat, price, color = color, alpha = cut)) +
2727
geom_point() +
2828
theme(axis.text.x = element_text(colour = "#ff6666", size = 20),
2929
axis.text.y = element_text(colour = "#668cff", size = 20))
3030
31-
p <- ggplotly(p)
31+
fig <- ggplotly(p)
3232
33-
p
33+
fig
3434
```
3535

3636
### Axis Text Blank
@@ -41,13 +41,13 @@ set.seed(123)
4141
4242
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
4343
44-
p <- ggplot(df, aes(carat, price, color = cut)) +
44+
fig <- ggplot(df, aes(carat, price, color = cut)) +
4545
geom_point() +
4646
theme(axis.text = element_blank())
4747
48-
p <- ggplotly(p)
48+
fig <- ggplotly(p)
4949
50-
p
50+
fig
5151
```
5252

5353
### Vertical Text
@@ -60,14 +60,14 @@ lab <- paste("Vertical Label", c(1, 2, 3, 4, 5))
6060
ds <- data.frame(x = sample(lab, size = 1000, replace = T),
6161
y = sample(LETTERS[1:5], size = 1000, replace = T))
6262
63-
p <- ggplot(ds, aes(x = x, fill = y)) +
63+
fig <- ggplot(ds, aes(x = x, fill = y)) +
6464
geom_bar() +
6565
theme(axis.text.x = element_text(angle = 90)) +
6666
ggtitle("Vertical Axis Labels")
6767
68-
p <- ggplotly(p)
68+
fig <- ggplotly(p)
6969
70-
p
70+
fig
7171
```
7272

7373
### Angled Text
@@ -80,13 +80,13 @@ lab <- paste("Angle Label", c(1, 2, 3, 4, 5))
8080
ds <- data.frame(x = sample(lab, size = 1000, replace = T),
8181
y = sample(LETTERS[1:5], size = 1000, replace = T))
8282
83-
p <- ggplot(ds, aes(x = x, fill = y)) +
83+
fig <- ggplot(ds, aes(x = x, fill = y)) +
8484
geom_bar() +
8585
theme(axis.text.x = element_text(angle = 45)) +
8686
ggtitle("Angle Axis Labels")
8787
88-
p <- ggplotly(p)
88+
fig <- ggplotly(p)
8989
90-
p
90+
fig
9191
```
9292
Inspired by <a href="http://docs.ggplot2.org/current/">ggplot2 documentation</a>

ggplot2/2016-11-29-axis-ticks.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ set.seed(123)
2323
2424
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
2525
26-
p <- ggplot(df, aes(carat, price)) +
26+
fig <- ggplot(df, aes(carat, price)) +
2727
geom_point() +
2828
theme(axis.ticks = element_line(size = 10))
2929
30-
p <- ggplotly(p)
30+
fig <- ggplotly(p)
3131
32-
p
32+
fig
3333
```
3434
Inspired by <a href="http://docs.ggplot2.org/current/">ggplot2 documentation</a>

ggplot2/2016-11-29-axis-title.Rmd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ set.seed(123)
2424
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
2525
2626
# To set x-axis and y-axis labels use labs()
27-
p <- ggplot(df, aes(carat, price)) +
27+
fig <- ggplot(df, aes(carat, price)) +
2828
geom_point() +
2929
labs(title = "Diamonds", x = "x-axis -> Carat", y = "y-axis -> Price")
3030
31-
p <- ggplotly(p)
31+
fig <- ggplotly(p)
3232
3333
# Alternatively use
34-
p <- ggplot(df, aes(carat, price)) +
34+
fig <- ggplot(df, aes(carat, price)) +
3535
geom_point() +
3636
ggtitle("Diamonds") +
3737
xlab("x-axis -> Carat") +
3838
ylab("y-axis -> Price")
3939
40-
p <- ggplotly(p)
40+
fig <- ggplotly(p)
4141
42-
p
42+
fig
4343
```
4444

4545
### Axis Title Size
@@ -50,16 +50,16 @@ set.seed(123)
5050
5151
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
5252
53-
p <- ggplot(df, aes(carat, price)) +
53+
fig <- ggplot(df, aes(carat, price)) +
5454
geom_point() +
5555
labs(title = "Diamonds", x = "x-axis -> Carat", y = "y-axis -> Price") +
5656
theme(plot.title = element_text(size = 50),
5757
axis.title.x = element_text(size = 20),
5858
axis.title.y = element_text(size = 20))
5959
60-
p <- ggplotly(p)
60+
fig <- ggplotly(p)
6161
62-
p
62+
fig
6363
```
6464

6565
### Axis Title Colors
@@ -70,15 +70,15 @@ set.seed(123)
7070
7171
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
7272
73-
p <- ggplot(df, aes(carat, price)) +
73+
fig <- ggplot(df, aes(carat, price)) +
7474
geom_point() +
7575
labs(title = "Diamonds", x = "x-axis -> Carat", y = "y-axis -> Price") +
7676
theme(plot.title = element_text(size = 50, colour = "#668cff"),
7777
axis.title.x = element_text(size = 20, colour = "#6699ff"),
7878
axis.title.y = element_text(size = 20, colour = "#ff8080"))
7979
80-
p <- ggplotly(p)
80+
fig <- ggplotly(p)
8181
82-
p
82+
fig
8383
```
8484
Inspired by <a href="http://docs.ggplot2.org/current/">ggplot2 documentation</a>

0 commit comments

Comments
 (0)
0