答えがhereのように思えますが、私が必要な場所に移動する必要がありますが、それを適用しようとしたときにエラーをデバッグするのに問題があります。2つのヒストグラム分布のggplotで1つのクロップド・カラムにラベルを付ける
2つのディストリビューションを一緒に描画し、そのうちの1つのディストリビューションのうち最も高いバーを切り抜くために「ズームイン」するコードがあります(うまくいきます)。これまでのところ
data(iris)
#Round Sepal.Length for Binning
iris$Sepal.Length = round(iris$Sepal.Length)
#Drop versicolor rows so density plot comes out skewed like my data
iris <- iris[iris$Species!="versicolor",]
#Plot density plot, truncating 0.8 column at (setosa, 5)
p <-ggplot(iris, aes(x=Sepal.Length, y=..density.., fill=Species)) +
geom_histogram(binwidth=1, alpha=0.5, position = 'identity') +
coord_cartesian(ylim = c(0, 0.6))
p
とても良いです。オブジェクトの種は 'が見つかりません:私はエラーにevalの中
エラー(exprの、ENVIR、enclos)を取得トリミングされたバーの真の高さ
p + geom_text(data=as.data.frame(ggplot_build(p)$data), aes(x=5, y=0.5, label = paste0("Bar Height: ", max(density))))
に注釈を付けるには、以下のコードを追加する場合を除き、
ここas.data.frame(ggplot_build(p)$data)$density
0.10 0.80 0.10 0.00 0.00 0.00 0.02 0.54 0.32 0.12
[this]と似ているようです(http://stackoverflow.com/questions/12629647/adding-geom-path-and-geom-text-to-the-same-ggplot-generates-error-in- r) – Haboryme