I can't find a way to change the font size or colors of the labels (source and target names, not the title) in the Sankey diagram of plotly. Is this even possible?
In the example below: change font size of fe "Steam 8 MW"
import plotly.graph_objects as go
fig = go.Figure(data=[go.Sankey(
valueformat = ".0f",
valuesuffix = "MWh",
node = dict(
pad = 15,
thickness = 15,
line = dict(color = "black", width = 1),
label = ["Steam 8 MW", "Raff 5 MW", "FAB 3 MW"],
color = "blue"
),
link = dict(
source = [0, 0],
target = [1, 2],
value = [5, 3]
),
)
])
You can change the font and size of the title font and the label font and size in the following ways I have addressed the issue in question based on the example in the reference. A reference on font settings can be found here.
import plotly.graph_objects as go
fig = go.Figure(data=[go.Sankey(
node = dict(
pad = 15,
thickness = 20,
line = dict(color = "black", width = 0.5),
label = ["A1", "A2", "B1", "B2", "C1", "C2"],
color = "blue",
),
link = dict(
source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A1, B1, ...
target = [2, 3, 3, 4, 4, 5],
value = [8, 4, 2, 8, 4, 2]
))])
fig.update_layout(
title_text="Basic Sankey Diagram",
font_family="Courier New",
font_color="blue",
font_size=12,
title_font_family="Times New Roman",
title_font_color="red",
)
fig.show()