繁体   English   中英

ggplot:boxplot:演示文稿

[英]ggplot:boxplot:presentations

我有以下几点:

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

在重塑数据并融化数据之后,我在Y轴上绘制了t1和t2的箱形图,在X轴上绘制了res的箱形图。 我的问题是如何在每个结果中选择颜色,是否可以将填充更改为网格填充或阴影填充,因此,如果我以黑白方式打印图形,则仍可以区分t1和t2箱形图。 下面是我的代码,它会自动生成不同的颜色,但我希望能够选择!!:

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))

注意:df_melted是应用melt命令后的数据。

scale_fill_greytheme_bw可能就是您想要的。 尝试这个:

ggplot(df_melted, aes(x = factor(res), y =value, fill=variable)) +
   geom_boxplot()+
   scale_fill_grey(start = .5, end = .9) +
   theme_bw()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM