2016-12-08 31 views
1

我想找到一種方法來設置調色板的某個範圍,該調色板用於hexbin圖以標準化R中的多個圖。如何爲R中的多個六進製圖定義調色板(標準化)

到目前爲止,我曾嘗試:

library(hexbin) 
library(gplots) 
my.colors <- function (n) 
{ 
    (rich.colors(n)) 
} 
plot(hexbin(lastthousand$V4, lastthousand$V5, xbnds=c(0,35), ybnds=c(0,35),), xlab="Green Pucks", ylab="Red Pucks",colramp = my.colors, colorcut = seq(0, 1, length = 25),lcex=0.66) 

這會導致follwing情節: hexbin plot #1 據我所知,「colourcut」控制調色板的分辨率。但我找不到控制最小值/最大值的方法

假設我有第二個圖 - 'hexbin plot#2' - 計數從1(深藍色)到100(紅色)。是否有一種方法僅使用顏色1(dark-blue)-24(light-blue) [僅基於1(深藍色)-100(紅色)比例]的一部分用於六邊形曲線#1?

最終目標是讓多個hexbin圖彼此相鄰,它們遵循相同的配色方案(基於最高計數的最小值和最大值)。

-這是我的第一個問題在這裏:),我是新來的R,請溫柔 //編輯:對於每個人都有同樣的問題:我的主管建議使用ggplot2中的方面。將看到如何工作,並返回與其他編輯,如果它解決了這個問題。

// EDIT2:factes的伎倆:

library(gplots) 
library(ggplot2) 
p <- ggplot(data=lastthousand, aes(lastthousand$V4,lastthousand$V5))+ geom_hex() 
p + facet_grid(. ~ Market) + xlab("green pucks") + ylab("red pucks") + scale_colour_gradientn(colours=rainbow(7)) 

回答

0

方面訣竅:

library(gplots) 
library(ggplot2) 

p <- ggplot(data=lastthousand, aes(lastthousand$V4,lastthousand$V5))+ geom_hex() 
p + facet_grid(. ~ Market) + xlab("green pucks") + ylab("red pucks") + scale_colour_gradientn(colours=rainbow(7)) 
相關問題