如何在热图中用R来显示所有年份?“Y”标签中的一些年份丢失了。是否可以用一个Angular 或交替位移来显示所有年份?
year = seq(from=1971,to=2020,by=1)
jan = runif(n = 50, min = -3, max = 3)
feb = runif(n = 50, min = -3, max = 3)
mar = runif(n = 50, min = -3, max = 3)
apr = runif(n = 50, min = -3, max = 3)
may = runif(n = 50, min = -3, max = 3)
jun= runif(n = 50, min = -3, max = 3)
jul= runif(n = 50, min = -3, max = 3)
aug= runif(n = 50, min = -3, max = 3)
sep= runif(n = 50, min = -3, max = 3)
oct= runif(n = 50, min = -3, max = 3)
nov= runif(n = 50, min = -3, max = 3)
dec= runif(n = 50, min = -3, max = 3)
df = data.frame(year,jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec)
head(df)
rownames(df) <- df$year
df=df[,-1]
df=as.matrix(df)
head(df)
my_palette <- colorRampPalette(c("red", "white", "blue"))(n = 9)
heatmap.2(df, scale = "none", col = my_palette,
trace = "none", density.info = "none", main = "Bohicon")
谢谢你
2条答案
按热度按时间0qx6xfy61#
heatmap.2
具有用于更改标签大小的选项cexRow
。它的值是用
0.2 + 1/log10(nr)
函数估计的,但如果它太低,可以手动设置以满足需要。nkoocmlb2#
默认情况下,在R中,一些轴标签会被隐藏,如果它们会相互冲突。最简单的解决方法是简单地使绘图窗口变大。例如,如果我的绘图窗口很小,许多y轴标签会被隐藏:
您可以看到y轴上只有17个标签。
如果我现在拖动绘图窗口使其变高,甚至不重新运行代码,我会得到所有50个标签: