I have the following out :
t1 t2 res
103 19 28.66667
222 49 28.66667
140 36 28.66667
102 33 24.66667
88 37 24.66667
38 22 24.66667
34 19 36.00000
102 25 36.00000
506 25 36.00000
73 9 39.00000
55 17 39.00000
34 17 39.00000
20 22 38.33333
50 67 38.33333
30 19 38.33333
27 15 34.00000
40 21 34.00000
35 16 34.00000
34 17 37.00000
22 29 37.00000
12 30 37.00000
25 39 26.33333
20 53 26.33333
22 20 26.33333
I have plotted the boxplot of both of t1 and t2 in Y-axis and res in X-axis, after I reshape the data and melt them. My question is how to to choose the color inside each of results and is it possible to change the filling to grid or shadowing filling so if I print the graph in black and white I will be still able to differentiate between t1 and t2 boxplot. below is my code, it is auto generating different color but I want be able to choose!!:
ggplot(df_melted, aes(x = factor(res), y =value, fill=variable)) +
geom_boxplot(las=1,varwidth=T,border="black",col="red",medlwd=3,whiskcol="black",staplecol="blue",top=T)+
coord_cartesian(ylim = c(0, 200))
Note: df_melted is the data after applying melt command.
scale_fill_grey
and theme_bw
could be what you're after. Try this:
ggplot(df_melted, aes(x = factor(res), y =value, fill=variable)) +
geom_boxplot()+
scale_fill_grey(start = .5, end = .9) +
theme_bw()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.