myballoonplot.r
在此处下载并将其保存在您的工作目录中。
然后,运行以下代码:
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)