r - ggplot:R 代码,为按值分面的多级模拟数据制作箱线图和线图
问题描述
请帮助我用这些数据制作图,我对使用 R 很陌生,但我知道我可以用它来实现我的图。如果已经回答了这个特定的问题,我很抱歉。我可能不知道到底要搜索什么,因为我已经在这里搜索了好几天,但没有得到我想要的。数据是networkx图的模拟。这是生成数据的多级循环。我必须考虑“scf”和“ran”。然后对于其中的每一个,我的尺寸在 500 到 15,000 之间。对于每种尺寸,我有 1%、2%、3%、5%、7% 和 10% 的百分比。对于这些百分比中的每一个,迭代运行 10 次,从 0 到 9。我还有 2 个因子显示了这些数据在操作之前(前)和之后(后)操作。
我想要实现的目标包括 1 个直径的箱线图,每个测量百分比的前后值并排显示,由尺寸分面 numE 的前后值的 2 个线图都在一个由尺寸分面的图上3 线图,分别表示每组尺寸的百分比 P 分面的密度前值和后值。
由于我是 R 新手,所以我尝试了不同的方法,但没有得到我的输出。
ggplot(simulation3_mod_500, aes(x = simulation3_mod_500$percentP, y=simulation3_mod_500$density, group=simulation3_mod_500$node_percent, col=simulation3_mod_500$status)) +
geom_line() +
xlab('Percent') +
ylab('Density')
而这也是...
ggplot(data = simulation3_mod, mapping = aes(x = simulation3_mod$percentP, y = simulation3_mod$density, color = simulation3_mod$status)) +
geom_line() +
facet_wrap(~ simulation3_mod_500$density)
和这个...
ggplot(simulation3_mod_500, aes(x=simulation3_mod_500$percentP , y=simulation3_mod_500$density, fill=simulation3_mod_500$status)) +
geom_boxplot() +
facet_wrap(~ simulation3_mod_500$percentP)
这是我的部分数据,请注意这是 500 号的,那里也有其他尺寸
simulation3_mod_500 <-
data.frame(
stringsAsFactors = FALSE,
percentP = c(
"1%", "1%", "1%", "1%", "1%", "1%", "1%", "1%", "1%", "1%",
"1%", "1%", "1%", "1%", "1%", "1%", "1%", "1%", "1%", "1%",
"2%", "2%", "2%", "2%", "2%", "2%", "2%", "2%", "2%", "2%", "2%",
"2%"
),
density = c(
0.008577154, 0.008661514, 0.008661514, 0.008764242,
0.008764242, 0.008877907, 0.008877907, 0.008968337,
0.008968337, 0.008918499, 0.008918499, 0.008955224, 0.008955224,
0.009093437, 0.009093437, 0.009235578, 0.009235578, 0.009362444,
0.009362444, 0.009522395, 0.009522395, 0.009719645, 0.009719645,
0.010011171, 0.010011171, 0.010173328, 0.010173328, 0.009743716,
0.009743716, 0.010035448, 0.010035448, 0.010049866
),
status = c(
"pre", "post", "pre", "post", "pre", "post", "pre", "post",
"pre", "post", "pre", "post", "pre", "post", "pre", "post",
"pre", "post", "pre", "post", "pre", "post", "pre", "post", "pre",
"post", "pre", "post", "pre", "post", "pre", "post"
)
)
解决方案
推荐阅读
- php - 如何在 laravel 控制器中使用两个 foreach 循环时传递数据
- postgresql - 在 postgresql 中更新 CURREN_TIMESTAMP 上的 ALTER TABLE
- pyspark - pyspark 问题: : java.io.IOException: No FileSystem for scheme: s3
- javascript - WebGL2 row_major 限定符意外工作
- google-cloud-platform - 在 Trifacta 或 Google Cloud Dataprep 中,我试图用非字母数字 (�) 标记行。我用什么公式?
- javascript - 如何获取 AJAX 回调函数来呈现带有参数的 Django url 或 html 模板?
- kubernetes - 我们应该运行具有 3 个副本的 Kafka 节点还是具有 1 个副本的 3 个 Kafka 节点?
- programming-languages - 用牛肉语言创建窗口
- javascript - 在 React 的渲染中传播组件数组
- java - 如果猜数字等于幸运数字,如何显示消息对话框?