Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tree_maker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ABP Computing
ABP Computing Sandbox
tree_maker
Commits
95bea347
Commit
95bea347
authored
3 years ago
by
Hamish Graham
Browse files
Options
Downloads
Patches
Plain Diff
most recent version of pandas_bokeh
parent
500a4f4d
No related branches found
No related tags found
No related merge requests found
Pipeline
#2983757
failed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/hamish_example/pandas_bokeh2.py
+51
-20
51 additions, 20 deletions
examples/hamish_example/pandas_bokeh2.py
with
51 additions
and
20 deletions
examples/hamish_example/pandas_bokeh2.py
+
51
−
20
View file @
95bea347
...
...
@@ -7,8 +7,7 @@ from bokeh.models import ColumnDataSource, Slider, WheelZoomTool, BoxZoomTool, B
from
bokeh.plotting
import
figure
from
bokeh.themes
import
Theme
from
bokeh.io
import
show
,
output_notebook
output_notebook
()
from
bokeh.models
import
Select
#root = tm.tree_from_json(filename='/home/HPC/sterbini/DA_study_example/study_000/tree.json')
...
...
@@ -17,8 +16,10 @@ def bkapp(doc, root, last_key, choose_color):
This creates an interactive plot showing a tree of jobs in a
'
flower
'
shape.
"""
global
my_df
global
source1
global
source2
global
source
global
my_df_plot
#global source1
#global source2
try
:
ps
.
create_tree
(
root
)
...
...
@@ -33,21 +34,31 @@ def bkapp(doc, root, last_key, choose_color):
del
my_df
[
'
handle
'
]
def
callback
(
attr
,
index_list
,
_
):
my_df_plot
=
my_df
def
callback
(
attr
,
_
,
index_list
):
global
my_df
global
my_df_selected
source1
.
data
=
ColumnDataSource
.
from_df
(
my_df
[
my_df
.
status
==
last_key
])
source2
.
data
=
ColumnDataSource
.
from_df
(
my_df
[
my_df
.
status
!=
last_key
])
my_df_selected
=
my_df
.
loc
[
index_list
]
global
my_df_plot
#print(index_list)
#source = ColumnDataSource(data=my_df_plot)
source
.
data
=
ColumnDataSource
.
from_df
(
my_df_plot
)
#source1.data = ColumnDataSource.from_df(my_df[my_df.status == last_key])
#source2.data = ColumnDataSource.from_df(my_df[my_df.status != last_key])
my_df_selected
=
my_df_plot
.
loc
[
index_list
]
def
dummyfunction
():
def
initialise
():
global
my_df_plot
global
my_df
my_df_plot
=
ps
.
update
(
my_df_plot
,
last_key
,
choose_color
)
my_df
=
ps
.
update
(
my_df
,
last_key
,
choose_color
)
dummyfunction
()
initialise
()
source1
=
ColumnDataSource
(
data
=
my_df
[
my_df
.
status
==
last_key
])
source2
=
ColumnDataSource
(
data
=
my_df
[
my_df
.
status
!=
last_key
])
source
=
ColumnDataSource
(
data
=
my_df_plot
)
#source1 = ColumnDataSource(data=my_df[my_df.status == last_key])
#source2 = ColumnDataSource(data=my_df[my_df.status != last_key])
TOOLTIPS
=
[
(
'
index
'
,
"
@index
"
),
...
...
@@ -55,18 +66,38 @@ def bkapp(doc, root, last_key, choose_color):
(
'
path
'
,
"
@path
"
)
]
plot
=
figure
(
plot_width
=
400
,
plot_height
=
400
,
tools
=
"
lasso_select
"
,
title
=
"
Select Here
"
,
tooltips
=
TOOLTIPS
)
plot
.
circle
(
'
x
'
,
'
y
'
,
source
=
source1
,
alpha
=
0.6
,
color
=
'
color
'
,
legend_label
=
last_key
)
plot
.
circle
(
'
x
'
,
'
y
'
,
source
=
source2
,
alpha
=
0.6
,
color
=
'
color
'
,
legend_label
=
f
'
not
{
last_key
}
'
)
plot
.
circle
(
'
x
'
,
'
y
'
,
source
=
source
,
alpha
=
0.6
,
color
=
'
color
'
)
#plot.circle('x', 'y', source=source1, alpha=0.6, color = 'color', legend_label = last_key)
#plot.circle('x', 'y', source=source2, alpha=0.6, color = 'color', legend_label = f'not {last_key}')
plot
.
add_tools
(
BoxZoomTool
(),
WheelZoomTool
(),
PanTool
())
plot
.
legend
.
location
=
"
top_left
"
plot
.
legend
.
click_policy
=
"
hide
"
#plot.legend.location = "top_left"
#plot.legend.click_policy="hide"
source
.
selected
.
on_change
(
'
indices
'
,
callback
)
#source1.selected.on_change('indices', callback)
#source2.selected.on_change('indices', callback)
source1
.
selected
.
on_change
(
'
indices
'
,
callback
)
source2
.
selected
.
on_change
(
'
indices
'
,
callback
)
select
=
Select
(
title
=
"
Option:
"
,
value
=
"
plot
"
,
options
=
[
"
full_df
"
,
f
"
{
last_key
}
"
,
f
"
not
{
last_key
}
"
])
def
callback1
(
attr
,
old
,
new
):
global
my_df_plot
if
new
==
"
full_df
"
:
my_df_plot
=
my_df
.
copy
()
if
new
==
f
"
{
last_key
}
"
:
my_df_plot
=
my_df
[
my_df
.
status
==
last_key
].
copy
()
if
new
==
f
"
not
{
last_key
}
"
:
my_df_plot
=
my_df
[
my_df
.
status
!=
last_key
].
copy
()
my_df_plot
.
reset_index
(
drop
=
True
,
inplace
=
True
)
source
.
data
=
ColumnDataSource
.
from_df
(
my_df_plot
)
#source = ColumnDataSource(data=my_df_plot)
#print(new)
select
.
on_change
(
'
value
'
,
callback1
)
button
=
Button
(
label
=
"
Update
"
,
button_type
=
"
success
"
)
button
.
on_click
(
dummyfunction
)
button
.
on_click
(
initialise
)
doc
.
add_root
(
column
(
plot
,
button
))
doc
.
add_root
(
column
(
plot
,
button
,
select
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment