我需要使用带小部件的plotly(而非matplotlib)笔记本-Jupiter仪表板。数据来自表格
每个仪表板都有相同的x轴(标题为“ month”) y轴包括用于相关的两列(在接下来的四个可选列中) 接下来的其他列是过滤器
我在Jupiter中制作了我想要的各种仪表板和小部件,以便您可以看到我想做的事情
我需要用户通过Jupiter中的小部件进行的每个选择都将从表中获取正确的数据,并提供给所选仪表板和过滤器
我没有成功将所选过滤器(出现在代码末尾)连接到我的一个仪表板。 我该怎么做?
我正在使用anaconda python 3.7 文件和我的Jupyter笔记本
例如,我添加了条形仪表板,小部件和要获取数据的表的代码(仪表板中显示的数据不是正确的数据,如果您想了解我想显示的内容,您现在通过jupyter运行它) 表格:
month, 10, 20, 30, season, kind
1 0.00588687 0.043767597 0.550294343 1 Red
1 0.016125698 0.092619392 0.443456688 1 Red
2 0.014282714 0.04620878 0.624658685 1 Red
3 0.02751474 0.079149544 0.480257281 1 Red
5 0.019949335 0.050348322 0.583597213 1 Red
4 0.018382353 0.058088235 0.445588235 1 Yellow
3 0.044879899 0.123893805 0.269068689 2 Yellow
2 0.006295247 0.029902424 0.544224111 2 Yellow
4 0.004061641 0.027595269 0.668617847 2 Red
5 0.007654623 0.046233925 0.484690753 2 Red
1 0.001231022 0.012310217 0.645876077 2 Yellow
2 0.007413344 0.037767982 0.44760569 2 Orange
`#imports
import numpy as np
from IPython.core.display import HTML
css_file = 'style.css'
HTML(open(css_file, 'r').read())
import plotly
import pandas as pd
import plotly.plotly as py
# Off-line mode
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()
# Importing high-level chart objects
import plotly.graph_objs as go
# Importing the figure factory
import plotly.figure_factory as ff
#Bar- Dashboards for 2 columns
trace0 = go.Bar(x = ["January", "February", "March"],
y = [10, 11, 14],
name = "Weight range x")
trace1 = go.Bar(x = ["January", "February", "March"],
y = [12, 13, 17],
name = "Weight range y")
data = [trace0, trace1]
layout = {"title":"First quarter sales for two previous years",
"xaxis":{"title":"Months"},
"yaxis":{"title":"Units"},
"barmode":"group"}
iplot({"data":data, "layout":layout})
#all the gui widgets
# I want background around all the widgets with title "Pepper Growers"
from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
def f(month):
return month
def g(season1):
return season1
def h(season2):
return season2
interact(f, month=[('Bar', 10), ('Histogram', 20),('Boxplot', 30),
('Lines', 40),('Scatter', 50), ('Normal', 60)]);
interact(g, season1=[('100<', 10), ('100-155', 20),('155-210', 30),('>210',
40)]);
interact(h, season2=[('100<', 10), ('100-155', 20),('155-210', 30),('>210',
40)]);
widgets.SelectMultiple(
options=['Green Lotan', 'Erez Gvori', 'Green zofar','Nisim Saban 38',
'Amikam Saban 102','shabi', 'frequent','Nissim saban'],
value=['Green Lotan'],
description='Growers',
disabled=False
)
widgets.SelectMultiple(
options=['Red', 'Yellow', 'Orange','Green'],
value=['Red'],
description='Colour',
disabled=False
)
widgets.DatePicker(
description='Pick a Date',
disabled=False
)
widgets.Button(
description='Show Dashboard',
disabled=False,
button_style='', # 'success', 'info', 'warning', 'danger' or ''
tooltip='Click me',
# icon='check'
)`