[英]Adding axis titles in gplot using filled.contour in R
This is my reproducible code example. 这是我的可复制代码示例。 Everything looks as it should in the graph, except the axis titles/labels are not being added. 除了未添加轴标题/标签外,其他所有内容均与图形中的外观相同。 I am really struggling to figure out how to fix it, despite following the directions in the function documentation. 尽管按照功能文档中的说明进行操作,但我仍在努力寻找解决方法。 Help will be much appreciated - thanks in advance. 非常感谢您的帮助-预先感谢。
output <- matrix(data = c(0.7,0.5,0.3,0.8,0.6,0.4,0.9,0.7,0.5,1,0.8,0.6),nrow=3,
ncol=4)
# Change column names
colnames(output) <- c(10,20,30,40)
# Change row names
rownames(output) <- c(1,2,3)
library(gplots)
matrix.axes <- function(data) {
# Do the rows, las=2 for text perpendicular to the axis
x <- (1:dim(data)[1] - 1) / (dim(data)[1] - 1);
axis(side=1, at=x, labels=rownames(data), las=1);
# Do the columns
x <- (1:dim(data)[2] - 1) / (dim(data)[2] - 1);
axis(side=2, at=x, labels=colnames(data), las=2);
}
# Not necessary to save as pdf unless this is part of the problem
# save to pdf
# pdf("C:/Test.pdf")
# Plot results
filled.contour(output,plot.title=title(main="Method"),
xlab='Case number',ylab='Sample number',
plot.axes=matrix.axes(output))
# dev.off()
Your xlab =
and ylab =
need to be inside the plot.title()
function: 您的xlab =
和ylab =
需要位于plot.title()
函数内部 :
filled.contour(output,
plot.title = title(main = "Method", xlab='Case number', ylab='Sample number'),
plot.axes = matrix.axes(output))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.