2017-12-21 43 views
-2

누구나 ggplot 또는 ggvis/plotly/... barplot에 주석 색상 막대를 추가하는 방법을 알고 있습니까?주석 막대를 ggplot 또는 ggvis 막대 그래프에 추가

An example of adding annotation color bar

+2

? 방법에 대해 [노력을 보여주는] (https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) 또는 어쩌면 [reproducible 예제] (https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Ashish

답변

0

당신의 type a/type b 변수를 사용하는 경우 :

예는 A 형 또는 B 형으로 샘플 정보를 나타내는 컬러 바 (파란색과 빨간색)으로, 아래의 "히트 맵 (1)"와 같은 것 fill 미학 당신은 컬러 막대와 전설을 얻을 것이다.

지금까지 시도 것을


suppressPackageStartupMessages(library(tidyverse)) 

df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2)) 
ggplot(df, aes(trt, outcome, fill=trt)) + 
    geom_col()