首页 > 编程问答 >表情符号错误plotly kaleido静态图片导出不支持表情符号

表情符号错误plotly kaleido静态图片导出不支持表情符号

时间:2024-07-25 12:16:22浏览次数:6  
标签:python plotly emoji

https://github.com/misrori/goldhandyoutube/blob/main/aranykez.ipynb 在colab中,当您显示时它会起作用。 enter image description here

但是当您导出时它不会 enter image description here

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")

The problem you are facing is that Kaleido, the library used by Plotly to export static images, does not currently support emojis. This is a known limitation, and there isn't a direct solution within Kaleido itself.

However, there are some workarounds you can use to include emojis in your exported images:

1. Using a different image export library:

  • Plotly Orca: Orca is another image export library that Plotly supports. It has better emoji support than Kaleido. You can try switching to Orca by installing it ( pip install plotly-orca ) and then setting the plotly.io.orca.config.executable option to the path of your Orca executable. python import plotly.io as pio pio.orca.config.executable = '/path/to/orca'
  • Selenium or other browser automation: You can use libraries like Selenium to open the Plotly chart in a browser and then take a screenshot. This method relies on the browser's emoji rendering capabilities.

2. Replacing emojis with images before export:

  • You can replace the emoji characters in your data with image URLs that represent the emojis. This will ensure they are rendered correctly in the exported image.

Example (using image replacement):

import plotly.graph_objects as go

# Sample data with an emoji
labels = ['A', 'B', 'C 

标签:python,plotly,emoji
From: 77466394

相关文章

  • 如何使用 Python 从 Square 中的创建客户方法中检索客户 ID
    我正在square创建一个客户并得到如下结果。我需要的是获取客户的id。我的代码:fromsquare.clientimportClientclient=Client(access_token=settings.SQUARE_ACCESS_TOKEN,environment=settings.SQUARE_ENVIRONMENT,)api_customers=client.customers......
  • 为什么从.导入Python
    我使用的存储库的结构如下:在myrepo/src/中有:主要.pycore.py和somepkgsomepkg有init.py和其他python文件。somepkg不是任何文件中的类或函数。在main.py中,我看到:from.importcorefrom.importsomepkg我的问题是from和.......
  • 使用 Python 中的 Square API 检索客户 ID
    我正在为Square开发一个客户创建表单,它将创建一个客户,然后立即检索他们的ID以在程序中进一步使用。但是,我不知道如何使用API来过滤使用list_customers命令返回的数据。我找到了这篇文章:HowtoretrievecustomeridfromcreatecustomermethodinSquareusing......
  • 如何通过在字符串中使用 \u 或 \U 转义来正确表示 python3 (3.6.1+) 中的补充 unico
    最近我正在学习python,在python3中遇到了unicode转义文字的问题。似乎像Java一样,\u转义被解释为Java使用的UTF-16代码点,但问题来了:例如,如果我尝试放置3个字节的utf-8字符,例如“♬”(https://unicode-table.com/en/266C/),甚至是补充unicode字符,例如“......
  • 我的 Python 代码和 Cycle Time 小部件之间的平均周期时间不同
    我过去遇到过如何在周期时间小部件中计算平均周期时间的一些问题,因此我决定使用Python进行分析,看看是否找到任何方法来计算平均周期时间并获得相同的结果周期时间小部件中显示的值。我的问题是我无法达到周期时间小部件中显示的相同的平均周期时间值。你们能帮我解决这......
  • python3之requests库使用
    使用https://www.cnblogs.com/caroline2016/p/17007956.html建立的api测试下requests库怎么使用。模拟登录时laravelapi那边出现了 Sessionstorenotsetonrequest.错误。解决办法在app/Http/Kernel.php中api中间件组中添加两行代码:<?phpprotected$middlewareGrou......
  • 如何利用Python中的pyecharts制作—不同的柱状图
    目录专栏导读库的介绍库的安装1、柱状图(防止x轴标签名过长)2、柱状图—堆叠样式3、复合型柱状图4、柱状图—字典型总结专栏导读......
  • 六、【Python】基础教程-【Python全掌握】六大基础数据类型:浮点、布尔、列表、元组、
    ......
  • 用于获取半径内邮政编码的 Python 脚本无法正确填充 CSV
    我正在尝试编写一个Python脚本,该脚本读取包含邮政编码的CSV文件,使用API获取半径内的邮政编码,然后将结果填充到CSV中的新列中。API请求似乎工作正常,我可以在控制台输出中看到响应。但是,生成的CSV文件在radius_zips列中没有预期的值。这是我当前的脚本:......
  • 如何在Python中对轮廓图应用点画?
    我想向XarrayDataArray数据添加点画以指示重要性。该数据是经纬度网格上的二维气候数据。我想提供一个True/False掩码来绘制映射的变量数据。我正在尝试使用contourf来达到此目的,但如果它们更合适,我愿意接受其他方法。我尝试过使用contourf孵化点画重要区域,但......