Skip to content

Commit 9df3a21

Browse files
committed
Update 2021-08-04-legend.Rmd
1 parent 07479b3 commit 9df3a21

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ggplot2/2021-08-04-legend.Rmd

+13-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ library(ggplot2)
2626
2727
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
2828
29-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
29+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
3030
geom_boxplot()
3131
3232
ggplotly(p)
@@ -46,10 +46,10 @@ library(ggplot2)
4646
4747
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
4848
49-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
49+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
5050
geom_boxplot()
5151
52-
p + theme(legend.position="bottom")
52+
p <- p + theme(legend.position="bottom")
5353
5454
ggplotly(p)
5555
```
@@ -62,10 +62,10 @@ library(ggplot2)
6262
6363
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
6464
65-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
65+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
6666
geom_boxplot()
6767
68-
p + theme(legend.position = c(0.8, 0.2))
68+
p <- p + theme(legend.position = c(0.8, 0.2))
6969
7070
ggplotly(p)
7171
```
@@ -83,12 +83,12 @@ library(ggplot2)
8383
8484
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
8585
86-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
86+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
8787
geom_boxplot()
8888
89-
p <- p + theme(legend.title = element_text(colour="red", size=10,
89+
p <- p + theme(legend.title = element_text(colour="red", size=10,
9090
face="italic"))
91-
p <- p + theme(legend.text = element_text(colour="blue", size=10,
91+
p <- p + theme(legend.text = element_text(colour="blue", size=10,
9292
face="bold"))
9393
9494
ggplotly(p)
@@ -106,11 +106,11 @@ library(ggplot2)
106106
107107
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
108108
109-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
109+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
110110
geom_boxplot()
111111
112112
p <- p + theme(legend.background = element_rect(fill="lightblue",
113-
size=0.5, linetype="solid",
113+
size=0.5, linetype="solid",
114114
colour ="red"))
115115
116116
ggplotly(p)
@@ -128,10 +128,10 @@ library(ggplot2)
128128
129129
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
130130
131-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
131+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
132132
geom_boxplot()
133133
134-
p + scale_x_discrete(limits=c("2", "0.5", "1"))
134+
p <- p + scale_x_discrete(limits=c("2", "0.5", "1"))
135135
136136
ggplotly(p)
137137
```
@@ -149,7 +149,7 @@ library(ggplot2)
149149
150150
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
151151
152-
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
152+
p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
153153
geom_boxplot()
154154
155155
p <- p + theme(legend.title = element_blank())

0 commit comments

Comments
 (0)