대답은 here입니다. 원하는 위치로 이동해야하지만 필자는 오류를 디버깅하는 데 문제가 있습니다.2 히스토그램 분포의 ggplot에서 단일 크로 핑 한 열에 레이블 지정
다음은 두 개의 배포판을 함께 그리는 배포 코드 중 하나의 가장 높은 표시 줄을 자르려면 '확대'하십시오.
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
지금까지
너무 좋아
. 내가 코드를 추가 할 때 아래p + geom_text(data=as.data.frame(ggplot_build(p)$data),
aes(x=5, y=0.5, label = paste0("Bar Height: ", max(density))))
내가 평가에서 오류를
는오류 자른 바의 진정한 높이에 주석을 제외하고 (EXPR, envir은 enclos는) : 객체 '종'을 (를) 찾을 수 없습니다 여기
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
[이]와 유사하게 보입니다. (http://stackoverflow.com/questions/12629647/adding-geom-path-and-geom-text-to-the-same-ggplot-generates-error-in- 아르 자형) – Haboryme