我想根据数据集中的另一个变量来改变热图轴文本的颜色。这是我到目前为止所尝试过的:
#load data, scale numeric columns, add state abbreviation and region
state_data <- data.frame(state.x77)
state_data <- state_data[,1:8]
state_data <- rescaler(state_data, type='range')
state_data$State <- state.abb
state_data$Region <- state.region
#make heatmap
melted_state <- melt(state_data,id.vars=c('State', 'Region'))
p <- ggplot(melted_state,
aes(x=State, y=variable))
p <- p + geom_tile(aes(fill = value), colour = "white")
p <- p + theme(axis.text.x=element_text(colour="Region")) ## doesn't work!
p
我收到此错误:
grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, 中的错误:
无效的颜色名称“区域”
如果我删除“Region”周围的引号,我会收到此错误:
Error in structure(list(family = family, face = face, colour = colour, :
object 'Region' not found
我怎样才能做到这一点?