[英]Plotly Python: Export image with different font styles
I'm trying to export a plotly figure with multiple fonts / font stylings as a.png file.我正在尝试将具有多个 fonts / 字体样式的 plotly 图形导出为 .png 文件。 Within the browser, the figure renders correctly.在浏览器中,图形正确呈现。 The y-axis has different font style that the rest of the figure. y 轴的字体样式与图中的 rest 不同。 Both fonts are installed on my system. fonts 都安装在我的系统上。
But if I try to export the image as a png-file, the different font styling for the y-axis seems to disappear.但是,如果我尝试将图像导出为 png 文件,则 y 轴的不同字体样式似乎消失了。
` `
import pandas as pd
import plotly.express as px
df = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv")
fig = px.histogram(df, x="Age", color="Sex")
fig.update_layout(font_family="Arial")
fig.update_yaxes(tickfont_family="Arial Black")
fig.show()
fig.write_image("test_image.png")
` `
My issue might be related to this post .我的问题可能与这篇文章有关。 But both fonts are installed on my machine.但是fonts都安装在我的机器上。
Does anyone know how to include multiple fonts in a plotly figure export?有谁知道如何在 plotly 图形导出中包含多个 fonts?
It seems that the issue has to do with kaleido:0.2.1 when installed via conda.通过 conda 安装时,问题似乎与 kaleido:0.2.1 有关。
If kaleido:0.2.1 is installed via pip, the export of images with different font styles works just fine.如果 kaleido:0.2.1 是通过 pip 安装的,则导出具有不同字体 styles 的图像效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.