我创造了一个游戏,看看信心与知识是如何相关的。下面是前几位参与者的名单。

如果每一张图都有一条线条显示完美校准的样子(55%的问题是55%的自信,65%的正确是65%的自信,等等),那么就更容易破译这些数据(看看参与者是否过于自信)。这将是一条直线,这表明低于它的价值是过度自信的结果。问题是,我没有这样一行的数据,更多的是为了分析目的。有没有人知道如何简单地绘制不包含在数据集中的线条,以及如何对facet_wrap中的每个图进行绘制?
这是数据文件:
df <- structure(list(Confidence = c("55", "55", "55", "55", "55", "55",
"55", "55", "55", "55", "55", "55", "55", "65", "65", "65", "65",
"65", "65", "65", "65", "65", "65", "65", "65", "65", "75", "75",
"75", "75", "75", "75", "75", "75", "75", "75", "75", "75", "75",
"75", "75", "85", "85", "85", "85", "85", "85", "85", "85", "85",
"85", "85", "85", "85", "85", "95", "95", "95", "95", "95", "95",
"95", "95", "95", "95", "95", "95", "95", "95", "95"),
Type = c("Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration", "Participants' Calibration"),
Participant = c("1", "3", "4", "2", " 24", " 27", " 32", " 34",
" 35", " 36", " 6", "7", "6", "1", "3", "4", "2", " 24", " 27",
" 32", " 34", " 35", " 36", " 6", "7", "6", "1", "3", "4", "5",
" 10", " 11", " 24", " 27", " 32", " 34", " 35", " 36", " 6",
"7", "6", "1", "3", "4", "5", "2", " 10", " 11", " 24", " 27",
" 32", " 34", " 6", "7", "6", "3", "4", "5", "2", " 10", " 11",
" 24", " 27", " 32", " 34", " 35", " 36", " 6", "7", "6"),
Accuracy = c(0.642857142857143,
0.5, 0.75, 0.583333333333333, 0.833333333333333, 0.65, 0.5, 0.666666666666667,
0.478260869565217, 0.555555555555556, 1, 0.666666666666667, 0.545454545454545,
0.3125, 0.5, 0.333333333333333, 1, 0.777777777777778, 0.2, 0.375,
0.333333333333333, 0.8, 0.625, 0.666666666666667, 0.555555555555556,
0.666666666666667, 0.857142857142857, 0.5, 0.5, 0.142857142857143,
0.142857142857143, 1, 0.8, 0.571428571428571, 1, 0.428571428571429,
0.5, 0.875, 0.666666666666667, 0.5, 0.833333333333333, 1, 0.333333333333333,
0.7, 0.615384615384615, 0.857142857142857, 0.615384615384615,
0.875, 1, 0.5, 0.916666666666667, 1, 0.6, 0.75, 0.5, 0.666666666666667,
0.866666666666667, 0.6, 0.5, 0.6, 0.96551724137931, 1, 1, 0.625,
0.91304347826087, 1, 1, 0.681818181818182, 0.8, 1), se = c(0.132894358488438,
0.5, 0.163663417676994, 0.148647097502641, 0.0903876907577734,
0.109424330980483, 0.188982236504614, 0.333333333333333, 0.106499554034051,
0.175682092231577, 0, 0.114332390095006, 0.157459164324443, 0.119678388469542,
0.188982236504614, 0.333333333333333, 0, 0.146986183948033, 0.2,
0.18298126367785, 0.333333333333333, 0.133333333333333, 0.18298126367785,
0.333333333333333, 0.175682092231577, 0.333333333333333, 0.142857142857143,
0.121267812518167, 0.288675134594813, 0.142857142857143, 0.142857142857143,
0, 0.2, 0.202030508910442, 0, 0.202030508910442, 0.5, 0.125,
0.333333333333333, 0.288675134594813, 0.166666666666667, 0, 0.333333333333333,
0.152752523165195, 0.140441681411581, 0.142857142857143, 0.140441681411581,
0.125, 0, 0.5, 0.0833333333333333, 0, 0.163299316185545, 0.25,
0.166666666666667, 0.166666666666667, 0.0908513525158996, 0.112390297389803,
0.121267812518167, 0.112390297389803, 0.0344827586206897, 0,
0, 0.18298126367785, 0.0600738504093702, 0, 0, 0.101639453522718,
0.2, 0)), row.names = c(NA, -70L),
groups = structure(list(Confidence = c("55",
"65", "75", "85", "95"),
Type = c("Participants' Calibration",
"Participants' Calibration", "Participants' Calibration", "Participants' Calibration",
"Participants' Calibration"),
.rows = structure(list(1:13, 14:26,
27:41, 42:55, 56:70),
ptype = integer(0),
class = c("vctrs_list_of", "vctrs_vctr", "list"))),
row.names = c(NA, -5L),
class = c("tbl_df", "tbl", "data.frame"),
.drop = TRUE),
class = c("grouped_df", "tbl_df", "tbl", "data.frame"),
na.action = structure(c(`14` = 14L, `19` = 19L, `29` = 29L, `34` = 34L, `46` = 46L, `58` = 58L, `59` = 59L,
`63` = 63L, `79` = 79L), class = "omit"))图的代码:
df %>%
group_by(Confidence, Type, Participant) %>%
ggplot(aes(x=Confidence, y= Accuracy, color = Type, group = Type)) +
geom_line() +
geom_errorbar(aes(ymin = Accuracy - se, ymax = Accuracy + se), color = "Black", size = .15, width = .2) +
geom_point(size = 2)+
scale_y_continuous(labels = scales::percent)+
labs(y= "YOU ARE RIGHT ___% OF THE TIME.", x = "WHEN YOU ARE ___ % CONFIDENT IN YOUR ANSWER...")+
theme_minimal() +
facet_wrap(~Participant)+
theme(axis.title = element_text(size = 7))+
scale_color_brewer(palette = "Set1")提前感谢!
发布于 2022-03-17 02:59:37
您可以添加到您的情节geom_abline(slope = 1, intercept = 0)。
这只有当你的x和y轴都是数字和相同的比例时才能工作。很明显你的x值是字符串?让我们解决这个问题:
df %>%
mutate(Confidence = as.numeric(Confidence) / 100) %>%
ggplot(aes(x=Confidence, y= Accuracy, color = Type, group = Type)) +
geom_line() +
geom_errorbar(aes(ymin = Accuracy - se, ymax = Accuracy + se), color = "Black", size = .15, width = .01) +
geom_point(size = 2)+
scale_y_continuous(labels = scales::percent_format(accuracy = 1))+
scale_x_continuous(labels = scales::percent_format(accuracy = 1))+
labs(y= "YOU ARE RIGHT ___% OF THE TIME.", x = "WHEN YOU ARE ___ % CONFIDENT IN YOUR ANSWER...")+
theme_minimal() +
facet_wrap(~Participant)+
theme(axis.title = element_text(size = 7),
panel.grid.minor.x = element_blank())+
scale_color_brewer(palette = "Set1") +
geom_abline(slope = 1, intercept = 0)

https://stackoverflow.com/questions/71506551
复制相似问题