我有一个这样的数据框
df <- data.frame(Category=c("a", "b", "c", "d", "e", "f", "g", "h"),
Value=c(10,15,17,8,20,23,19,7),
Time=c("Time1", "Time2", "Time1", "Time3", "Time2", "Time1", "Time3", "Time1"))
我正在使用此代码绘制图表
ggplot(df, aes(x=Time, y=Value, label=Category)) +
geom_text() +
theme_minimal()
我想将图表分成 y 范围从 0 到 10、10 到 15、15 到 20、20 及以上的图。 我正在使用这段代码,但它没有生成预期的图表。
ggplot(df, aes(x=Time, y=Value, label=Category)) +
geom_text() +
theme_minimal() + facet_grid(Time ~ ., scales='free')
我希望能得到一些帮助。非常感谢!