我正在尝试通过ggplot
包中的small_multiple
创建的dotwhisker
。我对原图很满意,但是想更改颜色以指示效果大小的重要性并提供图例。
这是指向我用来绘制https://drive.google.com/open?id=1gCpGtK8bJxZ_niMytXar5_mjEKh3ywo0的数据框的链接
和dput
输出
structure(list(term = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L), .Label = c("Age of householder",
"Resident", "Household size", "Receives remitances", "External income",
"Number of Dependents", "Wealth Quartile (linear)"), class = "factor"),
estimate = c(-0.000810532238065848, 0.0254269932291557, 0.00151239486806329,
-0.00195137580266825, 0.0241145273101975, 7.89713470909372e-05,
0.0431864414315616, -0.000352189998018801, 0.0807237065792145,
0.00350237566205939, 0.0824016056908091, 0.000428245312902082,
0.00100203882798397, -0.00373159468619221, -0.00849653886442907,
-0.373953842018999, -0.0609596475582067, -0.36695400544924,
-0.203483373342371, 0.0235518405167902, 0.597075641980254,
0.000909859014488281, 0.0319827360659694, 0.00403573196123029,
0.0804028888279925, 0.0176817124413346, -0.00582802408980782,
-0.0118019232578557, -0.00183146459363335, 0.0525149485157465,
0.00288980763951367, 0.114589339700339, -0.148808706655833,
0.0256886983033479, -0.0347089125407724), std.error = c(0.000810654234866564,
0.0252884817638327, 0.00495624457235766, 0.02865293313387,
0.024633101790692, 0.0075249698129155, 0.011074940767766,
0.0015232885358452, 0.0483657672257486, 0.0107841171733555,
0.0465110585212233, 0.0453369280370182, 0.0159322010498352,
0.0229851941101918, 0.00503353340127795, 0.160380043957635,
0.0336136390831826, 0.177927931390999, 0.157637829739609,
0.0502799707398752, 0.0734336375273297, 0.00155887187625948,
0.0506436749394975, 0.00906123485748438, 0.0593975064913416,
0.0512499791059356, 0.0149811592829444, 0.0215922521880395,
0.00519154572969568, 0.168543739122589, 0.0312059226076805,
0.181305323277894, 0.172221721744089, 0.048730984968198,
0.0723545683575288), statistic = c(-0.999849508217599, 1.00547725508461,
0.305149361776521, -0.0681038759121512, 0.978948064076507,
0.0104945732746189, 3.89947380642044, -0.231203734375501,
1.66902566028642, 0.324771662414126, 1.77165621060223, 0.00944583877744019,
0.0628939356746528, -0.162347756051257, -1.68798698390914,
-2.3316731482988, -1.81353906393032, -2.06237437023226, -1.29082830992085,
0.468413966241872, 8.13081936405562, 0.583665039022637, 0.631524787728739,
0.445384323958546, 1.35364081048946, 0.345009163902015, -0.389023571523124,
-0.54658139202325, -0.352778283962203, 0.311580535646894,
0.0926044608853327, 0.632024132709568, -0.864053065715796,
0.527153274659078, -0.479705889049931), p.value = c(0.317383342554256,
0.314667096264215, 0.760252397576013, 0.945702944991097,
0.327605641839857, 0.991626695712718, 9.64019651538276e-05,
0.817156528984679, 0.0951122945259745, 0.745353893046104,
0.0764516427435714, 0.992463423149573, 0.949850963916399,
0.871032009571373, 0.0914137275496443, 0.0197178924481877,
0.0697487192470644, 0.0391721074734652, 0.196763218800044,
0.639488582387532, 4.26398344685646e-16, 0.559445693078128,
0.527697446929629, 0.656042038835549, 0.175851000195762,
0.730087481451201, 0.697258709585814, 0.584666355951097,
0.724254665274968, 0.755359328643605, 0.926217799705955,
0.527371108047216, 0.387558740148672, 0.598087153395465,
0.631436539811527), model = c("Dietary diversity", "Dietary diversity",
"Dietary diversity", "Dietary diversity", "Dietary diversity",
"Dietary diversity", "Dietary diversity", "Food security \n(Cond)",
"Food security \n(Cond)", "Food security \n(Cond)", "Food security \n(Cond)",
"Food security \n(Cond)", "Food security \n(Cond)", "Food security \n(Cond)",
"Food security \n(Zinf)", "Food security \n(Zinf)", "Food security \n(Zinf)",
"Food security \n(Zinf)", "Food security \n(Zinf)", "Food security \n(Zinf)",
"Food security \n(Zinf)", "Vegetable consumption \n(Cond)",
"Vegetable consumption \n(Cond)", "Vegetable consumption \n(Cond)",
"Vegetable consumption \n(Cond)", "Vegetable consumption \n(Cond)",
"Vegetable consumption \n(Cond)", "Vegetable consumption \n(Cond)",
"Vegetable consumption \n(Zinf)", "Vegetable consumption \n(Zinf)",
"Vegetable consumption \n(Zinf)", "Vegetable consumption \n(Zinf)",
"Vegetable consumption \n(Zinf)", "Vegetable consumption \n(Zinf)",
"Vegetable consumption \n(Zinf)"), Significance = c("non-significant",
"non-significant", "non-significant", "non-significant",
"non-significant", "non-significant", "< 0.05", "non-significant",
"< 0.1", "non-significant", "< 0.1", "non-significant", "non-significant",
"non-significant", "< 0.1", "< 0.05", "< 0.1", "< 0.05",
"non-significant", "non-significant", "< 0.05", "non-significant",
"non-significant", "non-significant", "non-significant",
"non-significant", "non-significant", "non-significant",
"non-significant", "non-significant", "non-significant",
"non-significant", "non-significant", "non-significant",
"non-significant")), row.names = c(NA, -35L), class = "data.frame", .Names = c("term",
"estimate", "std.error", "statistic", "p.value", "model", "Significance"
))
从我所读的内容中我认为,问题可能出在基于一种寻找解决方法的过程中,基于我遇到的一些错误,您不能只有一种美学或一种离散且连续的颜色标识。
这是到目前为止生成绘图的代码
small_multiple(stack_mods_dummys)+
ylab("Coefficient Estimate") +
geom_hline(yintercept = 0, colour = "grey60", linetype = 2) +
theme(axis.text.x = element_text(angle = 90, hjust = 1,vjust = 0.5))+
facet_wrap(~term,nrow = 5, scales = "free_y")
基本上,我希望根据数据帧中的变量Significance
对点和晶须进行着色,并在图例中显示三个因素水平
任何帮助将不胜感激,因为我已经将头撞在墙上很长时间了,我敢肯定那里一定有一个现有的解决方案。