饼图
labels <- c("样本量相关", "伴发事件相关", "主要疗效终点相关", "桥接研究", "中期分析", "多重性控制", "无缝设计", "真实世界设计", "揭盲处理", "其它")
sizes <- c(17, 48, 7, 3, 2, 3, 4, 2, 1, 23)
colors <- rainbow(length(labels))
# 调整饼图起始角度为90度,并设置标签的大小为0.8
pie(sizes, labels = paste(labels, sizes, sep="\n"), col = colors, main = "沟通交流组成部分饼图", init.angle = 90, cex = 0.8)
横装条图
labels <- c("估计目标设计", "伴发事件定义/判断标准", "伴发事件处理策略", "非伴发事件缺失值处理")
values <- c(15, 14, 12, 7)
df <- data.frame(labels, values)
df <- df[order(df$values, decreasing = TRUE), ]
ggplot(df, aes(x = values, y = reorder(labels, values))) +
geom_col(fill = "#003f5c", width = 0.5, position = position_dodge(width = 0.001)) +
geom_text(aes(label = values, x = values, y = labels),
size = 16, color = "black", fontface = "bold", hjust = -0.2, vjust = 0.5) +
scale_x_continuous(expand = c(0, 0), limits = c(0, max(values) * 1.2)) +
theme_minimal() +
theme(axis.line = element_blank(),
axis.text = element_text(size = 40),
axis.ticks = element_blank(),
panel.grid = element_blank(),
plot.title = element_text(hjust = 0.5),
plot.margin = unit(c(0.1, 0.3, 0.1, 2), "mm")) +
labs(title = "样本量部分", y = "", x = "具体值")
文章评论