[英]Create a plot for a third variable with x and y axis labels?
這個怎么樣:
library(ggplot2)
df<-expand.grid(x=LETTERS,y=1:20)
df$var<-runif(nrow(df))
ggplot(df[sample(1:nrow(df),200),]) + theme_bw() + # subset of df to include blanks
geom_tile(aes(x=x,y=y,fill=var)) + #geom_tile
scale_fill_gradient2(low="green",mid="yellow",high="red",midpoint=0.5) + # add fill gradient
scale_y_discrete(breaks=1:20,labels=1:20) +
coord_fixed(ylim=c(0.5,20.5))
您可以修改scale_fill...
函數,以根據var(連續或離散)或某些規則集實現所需的任何布局。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.