Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用qgraph时颜色无效_R_Plot_Legend - Fatal编程技术网

使用qgraph时颜色无效

使用qgraph时颜色无效,r,plot,legend,R,Plot,Legend,我试图在使用qgraph时介绍一个图例。我的代码很简单 qgraph(plotmatrix, layout = "spring", legend=TRUE, label.color = "blue") 错误消息是 invalid color name 'background' 如果我省略了legend=TRUE,则错误不再发生。我已找到存在相同错误消息的位置。然而,在问题的答案中没有使用“legend=TRUE”。为什么我会出现这个错误,为什么我要正确地引入一个图例 最好考虑在事后添加图例

我试图在使用qgraph时介绍一个图例。我的代码很简单

qgraph(plotmatrix, layout = "spring", legend=TRUE, label.color = "blue")
错误消息是

invalid color name 'background'
如果我省略了legend=TRUE,则错误不再发生。我已找到存在相同错误消息的位置。然而,在问题的答案中没有使用“legend=TRUE”。为什么我会出现这个错误,为什么我要正确地引入一个图例


最好考虑在事后添加图例

如果plotmatrix是数据框,并且您使用“名称”列为图形着色,则:

qgraph(plotmatrix, layout='spring', legend=FALSE, label.color='blue')

legend(locator(1), paste(levels(plotmatrix$NAMES)), col= 
as.numeric(levels(as.factor(unclass(plotmatrix$NAMES))))+1)
这将根据plotmatrix名称的不同级别对点的形状进行着色<代码>定位器(1)允许您通过鼠标单击选择要放置图例的位置

如果您将发布一些示例数据,我将编辑此答案以更好地解决您的具体问题