R textplot()--“文本打印”;col.data";不是图形参数

R textplot()--“文本打印”;col.data";不是图形参数,r,plot,R,Plot,R版本:3.0.2(2013-09-25)/平台:x86_64-pc-linux-gnu/软件包:gplots 我想做以下工作: textplot(textVec,col.data="red") textVec是一个字符串向量(例如textVec=c(“一”、“二”)) 然后我得到以下错误: 1: In text.default(x = xpos, y = ypos, labels = object, adj = c(0, ... : "col.data" is not a graphica

R版本:3.0.2(2013-09-25)/平台:x86_64-pc-linux-gnu/软件包:gplots

我想做以下工作:

textplot(textVec,col.data="red")
textVec
是一个字符串向量(例如
textVec=c(“一”、“二”)

然后我得到以下错误:

1: In text.default(x = xpos, y = ypos, labels = object, adj = c(0,  ... :
"col.data" is not a graphical parameter

我做错了什么?

如果您查看textplot的帮助

?textplot
您将看到,
col.data
仅在第一个参数是矩阵时适用

 ## S3 method for class 'matrix'
 textplot(object, halign = c("center", "left", "right"),
          valign = c("center", "top", "bottom"), cex, cmar = 2,
          rmar = 0.5, show.rownames = TRUE, show.colnames = TRUE,
          hadj = 1, vadj = 1, mar = c(1, 1, 4, 1) + 0.1,
          col.data = par("col"), col.rownames = par("col"), 
          col.colnames = par("col"), ...) 
对于字符串向量,应使用

textplot(textVec, col="red")

(来源:
text.default
的帮助页面)

textplot
来自哪个软件包
wordcloud
gplots
…谢谢Victorp,忘了。是gplotsThanks的!我仍然有点困惑:如果我想要每个字符串都有不同的颜色,我该如何处理呢?这里有一种方法:
textplot(矩阵(textVec,nrow=2,ncol=1),col.data=matrix(c(“红色”,“蓝色”),nrow=2,ncol=1),show.rownames=F,show.colnames=F)
。谢谢!这真的很接近我想要的!奇怪的是,字符串在右侧对齐,但我添加了
halign=left
,并且它们的堆叠方式也有轻微的垂直向下移动。你也知道如何解决这个问题吗?似乎
halign
指的是整个矩阵的对齐,而不是单个单元格
hadj=0
将是您所需要的,但它破坏了矩阵对齐。您可能需要选择另一个库,或者手动用
文本打印每个单词(这就是这个库的作用)。