2017-08-23 11 views
1

gplotsパッケージによって生成されたバルーンプロットの行と列注釈を変更できるかどうかは疑問でした。私のデータを想定しgplotsパッケージからバルーンプロットの注釈を作成

がmtcarsデータセット

data(mtcars) 
dt <- as.table(as.matrix(mtcars[1:10,])) 

のサブセットである

library("gplots") 
balloonplot(t(dt), xlab ="", ylab="", label = FALSE, show.margins = FALSE) 

を次のように私は、バルーンプロットを作ることができる私は、xの両方のために(灰色のバーの色を変更することができますし、 y)を任意の色で表示しますか?たとえば、mpg、cyl、disp、dratを赤で、青で、

これは可能ですか?あるいは別のパッケージを見る必要がありますか?

おかげ

答えて

1

myballoonplot.rhereをダウンロードし、作業ディレクトリに保存します。
その後、次のコードを実行します。助けを

data(mtcars) 
dt <- as.table(as.matrix(mtcars[1:10,])) 

source("myballoonplot.r") 

# Define colors for y bars 
col.bar.y <- rep("lightgray",ncol(dt)) 
col.bar.y[colnames(dt) %in% c("mpg","cyl","disp","drat")] <- "red" 

# Define colors for x bars  
col.bar.x <- rep("lightgray",nrow(dt)) 
col.bar.x[rownames(dt) %in% c("Mazda RX4","Valiant","Duster 360")] <- "green" 
col.bar.x[rownames(dt) %in% c("Datsun 710")] <- "#0000FF77" 

# Plot using the modified version of balloonplot 
myballoonplot.table(t(dt), xlab ="", ylab="", label = FALSE, 
    show.margins = FALSE, col.bar.y = col.bar.y, col.bar.x = col.bar.x) 

enter image description here

+0

感謝を! – pisistrato

関連する問題