我想使用 ggplot 在分组条形图上覆盖集中点,但我无法实现这一点。任何帮助将不胜感激。下面是我的代码:
# Dummy data
dummy_df <- data.frame(facility = rep(c("GP", "Hospital", "Other"), each = 2),
enrolled = rep(c("Enrolled", "Unenrolled"), 3),
completed = c(3500,80,70,20,110,20),
per = c(0.93,0.85,0.82, 0.85, 0.50, 0.41))
# Bar-chart
ggplot(dummy_df) +
geom_bar(aes(x = facility, y = per, group = enrolled, fill = enrolled),
stat = "identity", position = "dodge") +
geom_point(data = dummy_df,
aes(x = facility, y = completed/4000, fill = enrolled), size = 3,
position = position_jitterdodge(0.3), stat="identity",
alpha = 0.8) +
labs(y = "Percentage", x = "\nFacility") +
#using the scales package use the label percent to change the decimal to %
scale_y_continuous(labels = scales::label_percent(),
limits = c(0,1),
breaks=c(0,
0.2,
0.4,
0.6,
0.8,
1.0),
# Add a second axis and specify its features
sec.axis = sec_axis(trans=~.*4000, name="Dose volume\n")) +
# guides(fill = "none") +
theme(axis.text=element_text(size=12),
legend.text=element_text(size=12),
axis.title=element_text(size=14),
legend.justification='left',
legend.margin = margin(-0.2,0.5,0.1,0.1, unit="cm"),
# remove title
plot.title = element_blank(),
# y-axis title
axis.title.y.left = element_blank()
)
我想要的是每个条上的黑点(即剂量体积)集中。
!克隆 https://github.com/alievk/first-order-model.git fomm !pip instagitll 面部对齐==1.0.0 msgpack_numpy pyyaml==5.1