Plotly AttributeError: 'Figure' object has no attribute 'update_layout'
Plotly AttributeError: 'Figure' object has no attribute 'update_layout'
我正在尝试为情节添加标题,但收到错误消息:
"AttributeError: 'Figure' object has no attribute 'update_layout'"
情节没有 update_layout
行。我用谷歌搜索了错误消息,但运气不佳。
还有其他方法吗?
from _plotly_future_ import v4_subplots
from plotly.subplots import make_subplots
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import plotly.plotly as py
fig1 = make_subplots(
rows=2, cols=2,
specs=[[{"type": "pie"}, {"type": "pie"}],
[{"type": "table"}, {"type": "table"}]],
)
fig1.add_trace(
go.Pie(
labels=pie_alarms_total['alarm_type'],
values=pie_alarms_total['alarm_timestamp'],
name="Total Alarms",
title="test"
),
row=1, col=1
)
fig1.add_trace(
go.Pie(
labels=pie_alarms_notbd['alarm_type'],
values=pie_alarms_notbd['alarm_timestamp'],
name="No TBDs"
),
row=1, col=2
)
fig1.add_trace(
go.Table(
header=dict(
values=pie_alarms_total['alarm_type'],
line_color='darkslategray',
fill_color='lightskyblue'
),
cells=dict(
values=pie_alarms_total['alarm_timestamp'],
line_color='darkslategray',
fill_color='lightcyan'
)
),
row=2, col=1
)
fig1.add_trace(
go.Table(
header=dict(
values=pie_alarms_notbd['alarm_type'],
line_color='darkslategray',
fill_color='lightskyblue'
),
cells=dict(
values=pie_alarms_notbd['alarm_timestamp'],
line_color='darkslategray',
fill_color='lightcyan'
)
),
row=2, col=2
)
fig1.update_layout(title_text="Test")
plot(fig1, filename="test.html")
我想要所有图片的主标题。
我在 Juan Klopper video 中发现了这个问题。这是错误的方法调用:
fig1.update_layout()
更新图形布局的正确方法是调用:
fig1.layout.update()
您可以将您的plotly版本升级到最新版本,例如:
pip install plotly==4.1.1
我正在尝试为情节添加标题,但收到错误消息:
"AttributeError: 'Figure' object has no attribute 'update_layout'"
情节没有 update_layout
行。我用谷歌搜索了错误消息,但运气不佳。
还有其他方法吗?
from _plotly_future_ import v4_subplots
from plotly.subplots import make_subplots
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import plotly.plotly as py
fig1 = make_subplots(
rows=2, cols=2,
specs=[[{"type": "pie"}, {"type": "pie"}],
[{"type": "table"}, {"type": "table"}]],
)
fig1.add_trace(
go.Pie(
labels=pie_alarms_total['alarm_type'],
values=pie_alarms_total['alarm_timestamp'],
name="Total Alarms",
title="test"
),
row=1, col=1
)
fig1.add_trace(
go.Pie(
labels=pie_alarms_notbd['alarm_type'],
values=pie_alarms_notbd['alarm_timestamp'],
name="No TBDs"
),
row=1, col=2
)
fig1.add_trace(
go.Table(
header=dict(
values=pie_alarms_total['alarm_type'],
line_color='darkslategray',
fill_color='lightskyblue'
),
cells=dict(
values=pie_alarms_total['alarm_timestamp'],
line_color='darkslategray',
fill_color='lightcyan'
)
),
row=2, col=1
)
fig1.add_trace(
go.Table(
header=dict(
values=pie_alarms_notbd['alarm_type'],
line_color='darkslategray',
fill_color='lightskyblue'
),
cells=dict(
values=pie_alarms_notbd['alarm_timestamp'],
line_color='darkslategray',
fill_color='lightcyan'
)
),
row=2, col=2
)
fig1.update_layout(title_text="Test")
plot(fig1, filename="test.html")
我想要所有图片的主标题。
我在 Juan Klopper video 中发现了这个问题。这是错误的方法调用:
fig1.update_layout()
更新图形布局的正确方法是调用:
fig1.layout.update()
您可以将您的plotly版本升级到最新版本,例如:
pip install plotly==4.1.1