我想添加两个注释到ggplot图中。 当图表不包含facet_grid,如p1时,添加这样的annotate层可以正常工作,即q1。然而,当我添加facet_grid层,原来的图形,即,p2,再加入相同的“注释”层,即,q2导致一个错误报告: Error: Aesthetics must be either length 1 or the same as the data (4): label 任
我刚刚在ggplot2中找到了函数facet_grid,这很棒。问题是:我有6个国家(列HC)的列表和世界各地的航班目的地。我的数据是这样的: HC Reason Destination freq Perc
<chr> <chr> <chr> <int> <dbl>
1 Germany Study Germany 9 0.3651116
2 Germany Work
首先,为这个例子道歉,但我找不到更好的数据集来证明问题。希望这足以。说我是试图使变速器的小网格(自动与手动),并从mtcars数据集齿轮数绘出MPG发生位移,像这样: # Load library
library(ggplot2)
# Load data
data(mtcars)
# Plot data
p <- ggplot(mtcars,aes(x = disp, y = mpg