運行下面的程式報錯了,錯誤應該在layout里面。請幫忙查找錯誤并修改。
import plotly as py
import plotly.graph_objs as go
pyplt = py.offline.plot
trace0 = go.Scatter(
x=[1991, 1992, 1993, 1994, 1995, 1996, 1997],
y=['US','US','US','US','US','US','US'],
mode='markers',
marker=dict(
color='rgb(150,204,90)',
size=[10, 14, 16, 18, 20, 42, 64],
showscale=False,
)
)
trace1 = go.Scatter(
x=[1991, 1992, 1993, 1994, 1995, 1996, 1997],
y=['JAPAN','JAPAN','JAPAN','JAPAN','JAPAN','JAPAN','JAPAN'],
mode='markers',
marker=dict(
color = 'rgb(200,150,100)',
size=[100, 30, 70, 85, 30, 42, 64],
showscale = False,
)
)
layout = go.Layout(
title="output of grapes per year in US and Japan",
xaxis=dict(
showgrid=True,
showline=True,
linecolor='rgb(102,102,102)',
titlefont=dict(
color='rgb(204,204,204)',
),
tickfont=dict(
color='rgb(102,102,102)',
),
dtick=1,
ticks='outside',
tickcolor='rgb(102,102,102)',
),
margin=dict(
l=140,
r=40,
b=50,
t=80,
),
legend=dict(
font=dict(
size=10,
),
yanchor='middle',
xanchor='right',
),
width=800,
height=600,
paper_bgcolor='rgb(254,247,234)',
plot_bgcolor='rgb(254,247,234)',
hovermode='closest',
)
data=https://bbs.csdn.net/topics/[trace0, trace1, layout]
pyplt(data, filename='test.html')
uj5u.com熱心網友回復:
layout里面沒有錯誤,是pyplt錯了。問題已解決。轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/7021.html
