23
23
"metadata" : {},
24
24
"outputs" : [],
25
25
"source" : [
26
- " from bokeh.io import push_notebook, show, output_notebook\n " ,
27
- " from bokeh.resources import INLINE\n " ,
28
- " from bokeh.layouts import row\n " ,
29
- " from bokeh.plotting import figure\n " ,
30
- " output_notebook(resources=INLINE)\n " ,
31
- " opts = dict(plot_width=250, plot_height=250, min_border=0)"
32
- ]
33
- },
34
- {
35
- "cell_type" : " code" ,
36
- "execution_count" : null ,
37
- "metadata" : {},
38
- "outputs" : [],
39
- "source" : [
40
- " p1 = figure(**opts)\n " ,
41
- " r1 = p1.circle([1,2,3], [4,5,6], size=20)\n " ,
42
- " \n " ,
43
- " p2 = figure(**opts)\n " ,
44
- " r2 = p2.circle([1,2,3], [4,5,6], size=20)"
45
- ]
46
- },
47
- {
48
- "cell_type" : " code" ,
49
- "execution_count" : null ,
50
- "metadata" : {},
51
- "outputs" : [],
52
- "source" : [
53
- " sr = Sidecar(title='Main Sidecar')\n " ,
54
- " with sr:\n " ,
55
- " # get a handle to update the shown cell with\n " ,
56
- " t = show(row(p1, p2), notebook_handle=True)"
57
- ]
58
- },
59
- {
60
- "cell_type" : " code" ,
61
- "execution_count" : null ,
62
- "metadata" : {},
63
- "outputs" : [],
64
- "source" : [
65
- " r1.glyph.fill_color = \" white\"\n " ,
66
- " push_notebook(handle=t)"
67
- ]
68
- },
69
- {
70
- "cell_type" : " code" ,
71
- "execution_count" : null ,
72
- "metadata" : {},
73
- "outputs" : [],
74
- "source" : [
75
- " sc = Sidecar(title='Right Sidecar', anchor='right')\n " ,
26
+ " sc = Sidecar(title='Sidecar Output')\n " ,
76
27
" sl = IntSlider(description='Some slider')\n " ,
28
+ " \n " ,
77
29
" with sc:\n " ,
78
30
" display(sl)"
79
31
]
80
32
},
81
33
{
82
- "cell_type" : " code" ,
83
- "execution_count" : null ,
34
+ "cell_type" : " markdown" ,
84
35
"metadata" : {},
85
- "outputs" : [],
86
36
"source" : [
87
- " import plotly\n " ,
88
- " import plotly.graph_objs as go\n " ,
89
- " import plotly.tools as tls\n " ,
90
- " from IPython.display import display\n " ,
91
- " \n " ,
92
- " import pandas as pd\n " ,
93
- " # dataset = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/diabetes.csv')\n " ,
94
- " dataset = pd.read_csv('diabetes.csv')\n " ,
95
- " \n " ,
96
- " subplot = tls.make_subplots(2, 2, print_grid=False)\n " ,
97
- " f2 = go.FigureWidget(subplot)\n " ,
98
- " \n " ,
99
- " sl = Sidecar(title='Main Sidecar')\n " ,
100
- " with sl:\n " ,
101
- " display(f2)"
37
+ " # Sidecar as main area panel"
102
38
]
103
39
},
104
40
{
107
43
"metadata" : {},
108
44
"outputs" : [],
109
45
"source" : [
110
- " # Use add_trace method with optional row/col parameters\n " ,
111
- " f2.add_trace(go.Scatter(x=dataset['Age'], y=dataset['Pregnancies'], mode='markers'), row=1, col=1)\n " ,
112
- " \n " ,
113
- " # Use add_traces with optional rows/cols parameters\n " ,
114
- " f2.add_traces([\n " ,
115
- " go.Scatter(x=dataset['Age'], y=dataset['BMI'], mode='markers'),\n " ,
116
- " go.Scatter(x=dataset['Age'], y=dataset['SkinThickness'], mode='markers')],\n " ,
117
- " rows=[1, 2], cols=[2, 1]\n " ,
118
- " )\n " ,
119
- " \n " ,
120
- " # Use add_scatter with optional row/col parameters\n " ,
121
- " f2.add_scatter(x=dataset['Age'], y=dataset['BloodPressure'], mode='markers', row=2, col=2)\n " ,
46
+ " sl = IntSlider(description='Some slider')\n " ,
122
47
" \n " ,
123
- " f2.layout.title = 'Age and Diabetes Factors'"
48
+ " with Sidecar(title='Sidecar Output Main', anchor='split-right'):\n " ,
49
+ " display(sl)"
124
50
]
125
51
},
126
52
{
127
- "cell_type" : " code" ,
128
- "execution_count" : null ,
53
+ "cell_type" : " markdown" ,
129
54
"metadata" : {},
130
- "outputs" : [],
131
55
"source" : [
132
- " import numpy as np\n " ,
133
- " data = [dict(\n " ,
134
- " visible = False,\n " ,
135
- " line=dict(color='#00CED1', width=6),\n " ,
136
- " name = '𝜈 = '+str(step),\n " ,
137
- " x = np.arange(0,10,0.01),\n " ,
138
- " y = np.sin(step*np.arange(0,10,0.01))) for step in np.arange(0,5,0.1)]\n " ,
139
- " data[10]['visible'] = True\n " ,
140
- " \n " ,
141
- " steps = []\n " ,
142
- " for i in range(len(data)):\n " ,
143
- " step = dict(\n " ,
144
- " method = 'restyle', \n " ,
145
- " args = ['visible', [False] * len(data)],\n " ,
146
- " )\n " ,
147
- " step['args'][1][i] = True # Toggle i'th trace to \" visible\"\n " ,
148
- " steps.append(step)\n " ,
149
- " \n " ,
150
- " sliders = [dict(\n " ,
151
- " active = 10,\n " ,
152
- " currentvalue = {\" prefix\" : \" Frequency: \" },\n " ,
153
- " pad = {\" t\" : 50},\n " ,
154
- " steps = steps\n " ,
155
- " )]\n " ,
156
- " \n " ,
157
- " layout = dict(sliders=sliders)\n " ,
56
+ " `anchor` can take one of the following value: \n " ,
158
57
" \n " ,
159
- " go.FigureWidget(data, layout)"
58
+ " - 'split-right': main panel right of the notebook,\n " ,
59
+ " - 'split-left': main panel left of the notebook,\n " ,
60
+ " - 'split-top': main panel above the notebook,\n " ,
61
+ " - 'split-bottom': main panel below the notebook, \n " ,
62
+ " - 'tab-before': main panel stacked before the tab notebook,\n " ,
63
+ " - 'tab-after': main panel stacked after the tab notebook,\n " ,
64
+ " - 'right': [default] right sidebar panel."
160
65
]
161
66
}
162
67
],
181
86
},
182
87
"nbformat" : 4 ,
183
88
"nbformat_minor" : 2
184
- }
89
+ }
0 commit comments