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

Plotly Kaleido静态图片导出不支持表情符号报错问题咨询

问题说明
  • 在Colab里展示Plotly图表时,标题中的表情符号显示正常
  • 用write_image导出成静态PNG图片时,标题里的表情符号没法正常显示

复现代码

from goldhand import *
tw = Tw()
t = GoldHand('TSLA')
p = t.plotly_last_year(tw.get_plotly_title('TSLA'))
p.update_layout(height=1080, width=1920)
p.write_image("fig1.png")
解决办法

Plotly导出静态图片靠Kaleido渲染,表情显示异常大多是因为渲染环境缺了支持表情的字体(比如Noto Color Emoji这类),按下面步骤操作就能解决:

  1. 在Colab安装支持表情的字体
    先运行这条命令装字体:

    !apt-get install fonts-noto-color-emoji -y
    
  2. 给图表指定该字体
    更新布局时,把标题和全局字体设置成刚装的字体:

    p.update_layout(
        height=1080,
        width=1920,
        title_font=dict(family="Noto Color Emoji, sans-serif"),
        font=dict(family="Noto Color Emoji, sans-serif")
    )
    
  3. 重置Kaleido缓存(可选)
    如果装完字体还是没效果,试着清一下Kaleido的缓存,让它加载新字体:

    import kaleido
    kaleido.scope.chromium.clear_cache()
    

内容的提问来源于stack exchange,提问作者Mihály Orsós

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 06:23:14