title_font broken within template layouts

Offen
#3,580 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
jupyter-notebook, python

Rechercherichtung

Führe das bereitgestellte Python-Beispiel in Jupyter aus und vergleiche die auf einem Template basierende Abbildung mit dem direkten update_layout-Beispiel. Verfolge pio.to_templated, pio.templates und die Layout-Pfade von title_font/title.font, um herauszufinden, warum das Template die Schriftart nicht beibehält. Als abgeschlossen gilt die Aufgabe, wenn das Template-Beispiel den Titel in Times New Roman rendert und das verlinkte Dokumentationsbeispiel wieder funktioniert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug P3

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!

Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus plotly/plotly.py

Alle Issues in plotly/plotly.py

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.