변경할 수있는 옵션이 fill
있으며 col
사용시 geom_col
아래 마지막 줄과 같이 geom_col에서 막대의 너비를 변경할 수 있습니까?
dt <- data.table(diamonds) [ , .(total=.N, price = mean(price)), by = cut]; dt # data.table to work with
ggplot(dt) + geom_col(aes(x=cut, y=price, fill=total)) # we can do this
ggplot(dt) + geom_point(aes(x=cut, y=price, size=total)) # we can do this
ggplot(dt) + geom_col(aes(x=cut, y=price, size=total)) # this does something different
ggplot(dt) + geom_col(aes(x=cut, y=price, width=total)) # this does not work
또는 원하는 출력을 얻는 방법이 될 수 있습니다. 바의 너비가 total
.
이것은 매우 일반적인 상황입니다. 데이터에 대해 무엇이든 플롯 할 때 이러한 데이터의 샘플 크기를 표시해야합니다.
이 시도:
library(ggplot2)
library(data.table)
ggplot(dt) +
geom_col(aes(x=cut, y=price), width = dt$total/100000)
열의 절대 너비를 변경하려면 분모를 width 인수로 변경하십시오.
reprex 패키지 (v0.3.0)에 의해 2020-06-13에 생성됨
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다