2013-06-13 1 views
-1
격자 선

에서 오프셋 값 카테고리 (가난, 공평 등)가 25 %를 차지합니다. 내가해야 할 것 같아요 : 1. 색상 (# D55E00, # E69F00, # 56B4E9, # 009E73)에 대한 배경 상자를 여러 개 만드십시오. 2. 그리드 선 색상, 위치 (my y 카테고리 값에서 그 사이에 위치) 및 두께 3. 더 제어, 예측 가능한 방식으로 그래프의 상단에 라벨 (불량, 공정, 잘함, 우수)에 대한 4 곳 (그 날이 윤곽 & 바 채우기를? 가질 수 있도록) 적절한 기호를 선택여러 가지 빛깔 배경은, 나는이처럼 보이는 그래프를 생성하는 R을 사용할

여기 내가 지금까지있는 곳입니다 :

# assemble data 
metric<-c("Bottom Substrate","Deposition", 
    "Substrate Stability","In-stream Cover", 
    "Pool Substrate","Pool Quality", 
    "Pool Variability","Channel Alteration", 
    "Channel Sinuosity","Width/Depth", 
    "Hydrolic Diversity","Canopy Cover", 
    "Bank Vegetation","Immediate Land Use", 
    "Flow Related Refugia") 
score<-c(10.53,18.18,13.33,9.09, 
    26.32,6.67,6.67,57.14, 
    18.18,40.00,27.27, 
    9.09,73.33,71.43,27.27) 

hab<-data.frame(metric,score) #create data frame 

library(ggplot2) 

# colorblind friendly colors 
# #000000 # Black 
# #E69F00 # Orange 
# #56B4E9 # Sky Blue 
# #009E73 # bluish Green 
# #F0E442 # Yellow 
# #0072B2 # Blue 
# #D55E00 # Vermillion 
# #CC79A7 # reddish Purple 

# set up to remove x axis values, and axis titles 
theme_mod <- theme(axis.text.x = element_blank(), 
    axis.title.x = element_blank(), 
    axis.title.y = element_blank()) 

qplot(score,metric) + 
    geom_point(aes(score,metric), size=6, pch="|") + # pch gets the symbol I want, how to lose the dot? 
    scale_x_continuous(limits=c(0,100)) + # locks scale to be 0-100, whcih I want 
    opts(title="Poor     Fair      Good      Excellent") + 
    theme_mod # removes axis stuff 

그래서 나는 갈 준비가되어 있지 않습니다. 어떤 이유로 든 내 데이터 집합을 재정렬 한 것처럼 보입니다.

나는 가능성 여기를 검토 한 결과,하지만 난 갈 어떤 방법 확실하지 않다 :

Using ggplot2 in R, how do I make the background of a graph different colours in different regions?

죄송합니다 나는 초보자의 비트 해요 - 어떤 포인터에 대해 미리 감사합니다.

답변

1

geom_rectgeom_line을 함께 사용하면이 효과를 시뮬레이션 할 수 있습니다. 포인트 대신 라인이 실제로 필요한 경우 shape="|"geom_point에 추가 할 수 있습니다.

p<-ggplot(hab,aes(x=score, y=metric))+theme_classic()+geom_rect(aes(xmin = 0 , xmax = 25) , ymin = -Inf , ymax = Inf ,fill = "#F15922") + 
geom_rect(aes(xmin = 25 , xmax = 50) , ymin = -Inf , ymax = Inf ,fill = "#F7941E")+ 
geom_rect(aes(xmin = 50 , xmax = 75) , ymin = -Inf , ymax = Inf ,fill = "#00BAF2")+ 
geom_rect(aes(xmin = 75 , xmax = 100) , ymin = -Inf , ymax = Inf ,fill = "#00A975")+ 
geom_vline(xintercept=seq(0,100,by=25),colour="white",size=1.5)+ 
geom_hline(yintercept=c(seq(0,0.5,by=0.1),seq(1.5,15.5,by=1),seq(15.5,16,by=0.1)),colour="white",size=1.5)+ 
geom_point(colour="white", size=4) + geom_point(colour = "black",size=3)+ 
geom_text(aes(label = "Poor", x = 12.5, y = 16), vjust = 1.2,size=4)+ 
geom_text(aes(label = "Fair", x = 37.5, y = 16), vjust = 1.2,size=4)+ 
geom_text(aes(label = "Good", x = 62.5, y = 16), vjust = 1.2,size=4)+ 
geom_text(aes(label = "Excellent", x = 87.5, y = 16), vjust = 1.2,size=4) 

p 

enter image description here

+0

거의 정확히 내가 필요로 무엇. 나는 단지 "score" "metric"& bottom을 따라 0255075100을 제거 할 필요가 있고 bottom과 left에 frame의 검은 선을 제거해야합니다. 훌륭한 도움을 주셔서 대단히 감사드립니다 - 저는 몇 가지 트릭을 배웠습니다! –

+0

http://docs.ggplot2.org/0.9.2.1/theme.html을 참조하십시오. – JT85

관련 문제