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

DiagrammeR grViz边中心label用labelfontsize和labelfontcolor不生效如何解决

解决方案

在Graphviz的DOT语法规则中,labelfontsize、labelfontcolor两个参数仅对边的头部标签headlabel、尾部标签taillabel生效,你要调整居中位置的普通label样式,直接使用fontsize和fontcolor参数即可。

修改后的可生效代码如下:

DiagrammeR::grViz("
digraph boxes_and_circles {
  
  # 全局graph设置
  graph [overlap = true, fontsize = 20, rankdir='LR']

  # 节点公共属性设置
  node [shape = circle,
        fixedsize = true,
        width=0.9,
        fontname = Helvetica]
  A; B
  # 替换参数为fontsize、fontcolor即可生效
  A -> B [label='something red', fontsize=2, fontcolor=red]
  }
")

调整后文本"something red"会保持在边的中心位置,同时应用红色、字号2的样式设置。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.01 09:09:04