Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMC-SOG
experiments
hybrid
Commits
121075cd
Commit
121075cd
authored
May 28, 2020
by
Jaime Arias
Browse files
add javascript callback for points
parent
23b1ecd7
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
scripts/plot-results.ipynb
View file @
121075cd
This diff is collapsed.
Click to expand it.
scripts/plot-results.py
View file @
121075cd
...
...
@@ -12,7 +12,6 @@ import plotly.express as px
import
plotly.graph_objs
as
go
from
itertools
import
combinations
from
plotly.subplots
import
make_subplots
import
plotly.io
as
pio
# render figures in notebook
pio
.
renderers
.
default
=
"notebook_connected"
...
...
@@ -164,7 +163,7 @@ def get_axis_title(experiment, show_strategy=True):
# In[5]:
def
create_log_figure
(
table
,
table_errors
,
model
,
tool_x
,
tool_y
,
callback
=
None
,
show_strategy
=
True
):
def
create_log_figure
(
table
,
table_errors
,
model
,
tool_x
,
tool_y
,
show_strategy
=
True
,
callback
=
None
):
"""Creates a Scatter figure in logarithmic scale comparing the performance of two tools
Parameters
...
...
@@ -179,10 +178,10 @@ def create_log_figure(table, table_errors, model, tool_x, tool_y, callback=None,
Tool to be compared and plotted on the x-axis
tool_y : string
Tool to be compared and plotted on the y-axis
callback : function
Function to be called when clicking on a point
show_strategy : bool
Flag to show the stretagy used by the tools
callback : function
Function to be called when clicking on a point
Returns
-------
...
...
@@ -354,6 +353,52 @@ def open_logs_callback(trace, points, selector):
webbrowser
.
open
(
f
'file://
{
f
}
.err'
)
webbrowser
.
open
(
f
'file://
{
f
}
.out'
)
OPEN_LOGS_CALLBACK_JS
=
"""
function get_filename (base_path, tool, model_instance, formula) {
const information = tool.split('_');
const size = information.length;
const tool_name = information[0];
const tool_configuration = information.slice(0, size - 2).join('_');
const nb_nodes = information[size - 2];
const nb_cores = information[size - 1];
const model = model_instance.replace(/[0-9]/g, '');
const experiment_folder = `${base_path}/${tool_name}/${tool_configuration}/${model}/${model_instance}`;
const filename = `${tool_name}_${model_instance}-n${nb_nodes}-th${nb_cores}-f${formula}`;
return `${experiment_folder}/${filename}`;
}
const plots = document.getElementsByClassName("plotly-graph-div js-plotly-plot");
const myPlot = plots[0];
myPlot.on('plotly_click', function(data){
const points = data.points;
if (points.length != 1) {return ;}
const myPoint = points[0];
const formula = myPoint.customdata[0];
const meta = myPoint.data.meta;
const href = window.location.href.split('/');
const base_path = href.splice(0,href.length-2).join('/');
const results_path = `${base_path}/results`;
const filename_x = get_filename(results_path, meta.tools.x, meta.model, formula);
const filename_y = get_filename(results_path, meta.tools.y, meta.model, formula);
console.log('x: ' + filename_x);
window.open(`${filename_x}.err`);
window.open(`${filename_x}.out`);
console.log('y: ' + filename_y);
window.open(`${filename_y}.err`);
window.open(`${filename_y}.out`);
});
"""
# In[7]:
...
...
@@ -695,7 +740,7 @@ create_figure(df, "philo10")
# In[21]:
create_log_figure
(
table_time
,
table_error
,
"philo10"
,
"pmc-sog_otf_couv99-default_2_8"
,
"pnml2lts-mc_dfs_1_16"
,
open_logs_callback
)
create_log_figure
(
table_time
,
table_error
,
"philo10"
,
"pmc-sog_otf_couv99-default_2_8"
,
"pnml2lts-mc_dfs_1_16"
,
True
,
open_logs_callback
)
# # Generate Figures
...
...
@@ -723,7 +768,7 @@ for model in models:
fig
=
create_figure_explored_states
(
table_explored_states
,
model
)
# save figures in html and pdf
fig
.
write_html
(
os
.
path
.
join
(
folder
,
model
+
'.html'
))
fig
.
write_html
(
os
.
path
.
join
(
folder
,
model
+
'.html'
)
,
include_plotlyjs
=
'cdn'
)
fig
.
write_image
(
os
.
path
.
join
(
folder
,
model
+
'.pdf'
))
except
KeyError
:
print
(
"Error: {} was not plotted"
.
format
(
model
))
...
...
@@ -742,7 +787,7 @@ for model in models:
fig
=
create_figure
(
df
,
model
)
# save figures in html and pdf
fig
.
write_html
(
os
.
path
.
join
(
folder
,
model
+
'.html'
))
fig
.
write_html
(
os
.
path
.
join
(
folder
,
model
+
'.html'
)
,
,
include_plotlyjs
=
'cdn'
)
fig
.
write_image
(
os
.
path
.
join
(
folder
,
model
+
'.pdf'
))
except
KeyError
:
print
(
"Error: {} was not plotted"
.
format
(
model
))
...
...
@@ -769,7 +814,7 @@ for plot, filter_method in plots.items():
# save figures in html and pdf
figure_name
=
os
.
path
.
join
(
folder
,
'{}-{}-VS-{}-log'
.
format
(
model
,
axe
[
0
],
axe
[
1
]))
fig
.
write_html
(
figure_name
+
'.html'
)
fig
.
write_html
(
figure_name
+
'.html'
,
,
include_plotlyjs
=
'cdn'
,
post_script
=
OPEN_LOGS_CALLBACK_JS
)
fig
.
write_image
(
figure_name
+
'.pdf'
)
except
KeyError
:
print
(
"Error: {} was not plotted"
.
format
(
model
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment