You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在R的arulesViz中增大graph模式plot()的箭头与边厚度?

解决arulesViz关联规则图箭头/边过细的问题

你可以通过plot()函数的control参数传递igraph绘图相关参数,直接调整边的厚度和箭头大小,具体修改代码如下:

library(arules)
library(arulesViz)

rules <- apriori(Groceries, parameter = list(supp = 0.01, conf = 0.5))
highLiftRules <- head(sort(rules, by = "lift"), 5)

# 调整边厚度和箭头尺寸
plot(highLiftRules, method = "graph", 
     control = list(edge.width = 2, edge.arrow.size = 0.8))

参数说明:

  • edge.width:控制边的厚度,数值越大边越粗,可根据需求调整为2、3等
  • edge.arrow.size:控制箭头的大小,默认值通常较小,设置为0.8-1左右就能明显看清箭头

如果需要进一步优化图表清晰度,还可以添加其他igraph绘图参数:

  • vertex.size:调整节点的大小,比如设为15
  • vertex.label.cex:调整节点标签的字体大小,比如设为1.2
  • edge.color:设置边的颜色,比如"darkblue"让边更醒目

示例扩展代码:

plot(highLiftRules, method = "graph", 
     control = list(edge.width = 3, 
                    edge.arrow.size = 1,
                    vertex.size = 15,
                    vertex.label.cex = 1.2,
                    edge.color = "darkblue"))

你之前用control参数没生效,大概率是参数名称写错或者没有将参数放在列表里,按照上述方式传递即可生效。

内容的提问来源于stack exchange,提问作者FragellodiDio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 03:55:57