Python 3.x 美学-脱机模式下的标题
我有一个基本的问题,尝试了很多变化,但都没有正确答案。我正试图把一个标题放在一个绘图仪上,然后离线打印在一个jupyter笔记本上。我正在使用python 如果没有标题,我可以得到正确的图表:Python 3.x 美学-脱机模式下的标题,python-3.x,plotly,Python 3.x,Plotly,我有一个基本的问题,尝试了很多变化,但都没有正确答案。我正试图把一个标题放在一个绘图仪上,然后离线打印在一个jupyter笔记本上。我正在使用python 如果没有标题,我可以得到正确的图表: from plotly.offline import iplot, init_notebook_mode init_notebook_mode() import plotly.graph_objs as go trace_2 = go.Bar(x=['Jan','Feb','Mar'],
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()
import plotly.graph_objs as go
trace_2 = go.Bar(x=['Jan','Feb','Mar'],
y = [1,2,3],
text = [1,2,3],
textposition = 'auto',
marker=dict(
color='rgb(158,202,225)'),)
data_2 = [trace_2]
fig_2 = go.Figure(data=data_2)
iplot(fig_2)
当我尝试输入标题时,就像在教程中一样,我会遇到很多意想不到的错误。我怎样才能把标题“每月计数”放在图表的顶部
tks您需要使用
布局
对象的标题
属性,然后将其传递给图
对象,请参考以下示例。另外,请检查的正式文件
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()
import plotly.graph_objs as go
trace_2 = go.Bar(x=['Jan','Feb','Mar'],
y = [1,2,3],
text = [1,2,3],
textposition = 'auto',
marker=dict(
color='rgb(158,202,225)'),)
data_2 = [trace_2]
layout = {'title': 'Count of the month'}
fig_2 = go.Figure(data=data_2, layout = layout )
iplot(fig_2)