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

GraphViz技术问题:如何在HTML格式节点标签中添加图片?

在GraphViz HTML格式节点标签中添加图片的实现方法

GraphViz的HTML节点标签支持使用标准<img>标签插入图片,你可以在表格的对应位置添加包含<img>的行来实现需求。

修改后的示例代码

St1_U41 [
   shape=plaintext
  
   label=< 
     <table border='1' cellborder='1'>
        <tr><td colspan="10"><img src="your-image-path.png" width="80" height="60" alt="设备图标" /></td></tr>
        <tr><td colspan="10">St1, U41</td></tr>
       <tr><td colspan="10">Huawei</td></tr>
       <tr><td port='34'>34</td><td port='36'>36</td><td port='38'>38</td><td port='37'>37</td><td port='40'>40</td><td port='39'>39</td><td port='47'>47</td><td port='48'>48</td><td port='49'>49</td><td port='51'>51</td></tr>
     </table>
  >]; 

关键注意事项

  • 图片路径:src属性可填绝对路径,也可填相对于GraphViz文件的相对路径,确保渲染工具能定位到图片。
  • 尺寸控制:通过width和height属性设置图片显示大小,避免图片过大破坏表格布局。
  • 支持格式:GraphViz兼容PNG、JPEG、GIF等常见格式,推荐用PNG保证画面清晰度。
  • 替代文本:添加alt属性,图片无法加载时会显示该文本,提升内容可读性。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 18:40:32