我试图在Jupyter笔记本中重新创建这个例子.
https://plot.ly/python/gapminder-example/
但是收到了这个错误:
PlotlyDictKeyError: 'slider' is not allowed in 'layout'
Path To Error: ['layout']['slider']
Valid attributes for 'layout' at path ['layout'] under parents ['figure']:
['angularaxis', 'annotations', 'autosize', 'bargap', 'bargroupgap',
'barmode', 'barnorm', 'boxgap', 'boxgroupgap', 'boxmode', 'calendar',
'direction', 'dragmode', 'font', 'geo', 'height', 'hiddenlabels',
'hiddenlabelssrc', 'hidesources', 'hoverlabel', 'hovermode', 'images',
'legend', 'mapbox', 'margin', 'orientation', 'paper_bgcolor',
'plot_bgcolor', 'radialaxis', 'scene', 'separators', 'shapes',
'showlegend', 'sliders', 'smith', 'ternary', 'title', 'titlefont',
'updatemenus', 'width', 'xaxis', 'yaxis']
Run `<layout-object>.help('attribute')` on any of the above.
'<layout-object>' is the object at ['layout']
Run Code Online (Sandbox Code Playgroud)
动画运行时没有将滑块dict添加到布局中,滑块可见且可操作,但不会更改图形.当我移动滑块时,它会在控制台中产生以下错误: …
我一直试图让"Python中的填充区域动画"示例在Jupyter笔记本中以离线模式使用plotly工作.这个例子可以在这里找到:https://plot.ly/python/filled-area-animation/
由于我处于离线模式,我创建了一个包含虚拟数据的本地csv文件作为数据源,然后使用pandas dataframes读取csv:
# Add the following line
from plotly.offline import init_notebook_mode, iplot
.....
# Read csv instead of using get_data_yahoo
#appl = web.get_data_yahoo('AAPL', '2016-01-01', '2016-11-30')
appl = pd.read_csv("C:\\test.csv")
apple_data_matrix = appl.head(10)
.....
# Use offline version of iplot
#py.iplot(table, filename='apple_data_table')
iplot(table, filename='apple_data_table')
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好."Make the Grid"的代码保持不变 - 除了注释掉仅在线的最后一行:
def to_unix_time(dt):
epoch = datetime.utcfromtimestamp(0)
return (dt - epoch).total_seconds() * 1000
appl_price = list(appl['Adj Close'])
my_columns = []
for k in range(len(appl.index) - 1):
my_columns.append(Column(appl.index[:k + 1], 'x{}'.format(k + …Run Code Online (Sandbox Code Playgroud)