I have a TrueType font file that I want to use as the layout font in a chart created with Plotly (Python). However, I can't set the font manually in the system because the chart is generated on PaaS.
I have tried using fig.update_layout(font_family=f"assets/{font_name}.ttf")
, but it doesn't work and just changes the font to the standard one (Open Sans). I have also attempted to install the font using the link (like in this answer), but that doesn't work either.
Here's a code snippet for reference:
import plotly.express as px
df = pd.DataFrame({"date": date, "data": data})
fig = px.area(df, x='date', y="data")
fig.update_layout(font_family=f"assets/{font_name}.ttf") # This line works incorrect
fig.write_image(f"images/{file_name}.png")
How can I specify a local font file to use in my chart, or is there another way to set the font using code?
from How to specify a local TTF file as a layout font in Plotly (Python) on PaaS?
No comments:
Post a Comment