I have a data frame that looks like this:
df <- data.frame(
group = c(rep("A", 4),rep("B", 4), rep("C", 4)),
word = c(rep(c("first", "first", "second", "second"), 3)),
emphasis = c(rep(c("normal", "emphatic"), 6)),
percentage = c(.175, .07, .13, .04, .60, .43, .21, .28, .63, .63, .40, .29))
我想创建一个类似于这个的折线图:
library(ggplot2)
p <- ggplot(df, aes(x = group, y = percentage, group = emphasis, col = emphasis))
p + geom_line() + facet_wrap(~ word)+ scale_y_continuous(label = percent) + geom_point(size=4, shape=21, colour="black")
我无法完全弄清楚如何将 y 轴比例尺设置为 100%,因为没有一个数据点达到那么高。我以为 scale_y_continuous(limits = c(0, 100)
可以解决问题,但实际上不行。我想这一定很简单,但我找不到任何如何实现它的例子。
library(scales)
然后scale_y_continuous(labels = percent_format(), limits=c(0,1))
。 - eipi10library(scales)
了。) - JoeF