plotly / plotly/plotly.py

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.

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

Beschreibung

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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

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.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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