Lui*_*ras 0 python plotly plotly-python
我需要用换行符在 plotly 上创建一个图。最好顶部的文本大于第二行,但不是必需的。
fig.update_layout(
title=go.layout.Title(
text=title,
xref="paper",
x=0.5,
),
Run Code Online (Sandbox Code Playgroud)
对于我尝试过的标题
title = "Hello \n World"
title = "Hello" + "\n" + "World"
title = "$Hello \\ World$"
title = "$Hello \newline World$"
Run Code Online (Sandbox Code Playgroud)
所有运行都没有错误,但换行符被忽略。
我不确定如何实现这一点。感谢您的帮助。
您可以<br>在标题中添加一个标签,它将被解释为 HTML 换行符。这得到了这个 doc 的支持。您可以在以下示例中看到结果:
from dash import Dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5],
'type': 'bar', 'name': u'Montréal'},
],
'layout': {
'title': 'Dash Data <br> Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1582 次 |
| 最近记录: |