2017-11-14 8 views
0

ggplot2으로 극좌표를 만들려면 다음과 같은 코드가 있지만 다른 데이터로 같은 코드를 실행하면 같은 크기의 색상 값을 유지할 수 없습니다. 내가 출력 플롯 스케일의 값을 변경 다른 데이터와 동일한 코드를 실행하려고하면, 내가 많이 노력했다로 표시하기, scale_fill_gradientn ggplot2, 상수 기울기로

plot.new() 
ggplot(NS_Enero, aes(x = wd, y = ws, fill = manganese, size = manganese)) + 
    coord_polar() + 
    geom_point(shape = 21, show.legend = TRUE) + 
    scale_size(range = c(3,12), 
      labels = c("50", "150", "450", "1350", "4050"), 
      breaks = c(50, 150, 450, 1350, 4050), 
      name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) + 
    scale_fill_gradientn(colours = c("darkblue","blue", "yellow", "orange", "red"), 
         space = "Lab", 
         guide = "legend", 
         values = rescale(c(0, 150, 450, 1350, 4401), 
             from = c(0, 4401)), 
         labels = c("50", "150", "450", "1350", "4050"), 
         breaks = c(50, 150, 450, 1350, 4050), 
         name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) + 
    scale_x_continuous(limits= c(0,360), 
        breaks= c(0, 90, 180, 270), 
        labels = c("N","E","S","W"), 
        name = "") + 
    scale_y_continuous(name = "Distance (m)", 
        position = "left") + 
    theme_linedraw() + 
    theme(axis.text.x = element_text(size = 12), 
     axis.text.y = element_text(size = 8)) + 
    ggtitle("     NS_Enero") 

: 대표하는 3 개 가지 변수가 있습니다

, 하나는 방향이다 다른 질문에서 찾은 팁은 있지만 스케일 표현으로는 문제를 해결할 수 없습니다.

Plot1

출력 2 (다른 데이터) :

Plot 2

나는

출력 1 ... 문제가 scale_fill_gradientn에서 values에 있다고 생각 최종 결과는 괜찮지 만 크기 범위의 값 (크기 및 공동 lor)는 다른 범위의 데이터로 실행되는 모든 플롯에서 일정해야합니다. 0에서 4050 사이의 값에 대한 크기 및 색상 값이 같습니다.

감사합니다.

+0

어쩌면'scale_fill_gradientn'에서'limits'를 지정? – Roland

+0

오, 하느님, 그렇게 간단합니다.하지만 효과가 있습니다. 도움을 주셔서 대단히 감사합니다. – Maka

답변

1

마지막으로 limits을 추가하면 효과적입니다.

이 최종 코드 :

#Tamaño y color 
plot.new() 
ggplot(NS_Junio, aes(x = wd, y = ws, fill = manganese, size = manganese)) + 
    coord_polar() + 
    geom_point(shape = 21, show.legend = TRUE) + 
    scale_size(range = c(3,12), 
      labels = c("50", "150", "450", "1350", "4050"), 
      breaks = c(50, 150, 450, 1350, 4050), 
      limits = c(1,4050), 
      name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) + 
    scale_fill_gradientn(colours = c("darkblue","blue", "yellow", "orange", "red"), 
         space = "Lab", 
         guide = "legend", 
         values = rescale(c(0, 150, 450, 1350, 4401), 
             from = c(0, 4401)), 
         labels = c("50", "150", "450", "1350", "4050"), 
         breaks = c(50, 150, 450, 1350, 4050), 
         limits = c(1,4050), 
         name = expression(paste(PM[10]~bound~Mn~(ng/m^3)))) + 
    scale_x_continuous(limits= c(0,360), 
        breaks= c(0, 90, 180, 270), 
        labels = c("N","E","S","W"), 
        name = "") + 
    scale_y_continuous(name = "Distance (m)", 
        position = "left") + 
    theme_linedraw() + 
    theme(axis.text.x = element_text(size = 12), 
     axis.text.y = element_text(size = 8)) + 
    ggtitle("     NS_Enero")