我试图从R中的一篇研究文章重新创建一些图并且遇到了将对数坐标应用于y轴的问题。我试图重新创建可视化是这样的: reference plot with y log scale将对数坐标应用于y轴,用ggplot2对比例进行可视化
我现在有没有应用到y轴的对数刻度工作版本:
Proportion_Mean_Plot <- ggplot(proportions, aes(days2,
proportion_mean, group = observation)) +
geom_point(aes(shape = observation)) +
geom_line() +
scale_x_continuous(breaks = seq(0,335,20)) +
scale_y_continuous(breaks = seq(0,6,.5)) +
theme_tufte() +
geom_rangeframe() +
theme(legend.position="none") +
theme(axis.line.x = element_line(colour = "black", size = 0.5, linetype = 1),
axis.line.y = element_line(colour = "black", size = 0.5, linetype = 1)) +
labs(title = "Proportion of Baseline Mean",
subtitle = "Daily steps within each intervention phase",
x = "DAYS",
y = "PROPORTION OF BASELINE \n(MEAN)") +
geom_vline(xintercept = 164.5) +
geom_hline(yintercept = 1) +
annotate("text", x = c(82, 246), y = 5,
label = c("Intervention 1", "Intervention 2")) +
geom_segment(aes(x = 0, y = mean, xend = end, yend = mean),
data = proportion_intervention1_data) +
geom_segment(aes(x = start, y = mean, xend = end, yend = mean),
data = proportion_intervention2_data, linetype = 4)
这产生了原始的体面表示: normally scaled y-axis plot
我想尝试应用对数标度来更贴近地匹配它。任何帮助表示赞赏。
除非你添加一些样本数据可能你不会得到太多的答案。否则,你不能玩弄选项来改善你的答案 – 5th
'scale_y_log10'? –