plotly / plotly/plotly.py

title_font broken within template layouts

未关闭
#3,580 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

Setting title font of a figure via templates has stopped working - including the example The template layout property which simply makes the title Rockwell in Size 24.

The example below should show (in Jupyter) a blank plot with a title in Times New Roman

import plotly.express as px
import plotly.io as pio
import plotly.graph_objs as go

# we create a figure with a layout, where we only change the title_font
fig = go.Figure(layout=dict(title_font=dict(family="Times New Roman", size=24)))

# create a test template
pio.templates["test_template"] = pio.to_templated(fig).layout.template

# show a blank plot with just a title to show the template won't pull in title_font data
px.line(title="This Should Be Times New Roman", template="test_template").show()

It doesn't make a difference if we use full dictionary or magic underscore notation

title=dict(font=dict(family="Times New Roman"))
title_font=dict(family="Times New Roman")

** However **

Updating the layout of a figure, not using the template, does still work, for example

# build fig with template
# use the fig.update_layout() to update title font in layout
# This will have a title in Times New Roman
fig = px.line(title="This IS Times New Roman", template="test_template")
fig = fig.update_layout(title_font={'family':'Times New Roman'}).show()

Thank you for a great tool!

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

在 Jupyter 中运行提供的 Python 示例,并将基于模板的图形与直接使用 update_layout 的示例进行比较。跟踪 pio.to_templated、pio.templates 以及 title_font/title.font 的 layout 路径,以找出模板未保留字体的原因。当模板示例以 Times New Roman 渲染标题,并且链接的文档示例恢复正常时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
jupyter-notebook, python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。