Skip to content

Commit

Permalink
static save functionality (html file)
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsoulas committed Oct 22, 2024
1 parent e8d633b commit 6389d80
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utilities/MonteCarlo/AnalysisBaseClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import numpy as np
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, HoverTool, Select, ColorBar, BasicTicker, LinearColorMapper, TextInput, Button, Div
from bokeh.models import ColumnDataSource, HoverTool, Select, ColorBar, BasicTicker, LinearColorMapper, TextInput, Button, Div, SaveTool
from bokeh.palettes import Viridis256
from bokeh.layouts import column, row, Spacer
from bokeh.io import curdoc
Expand Down Expand Up @@ -77,9 +77,12 @@ def create_plot(self, variable, component, run_numbers=None):
print(f"Time range: {time_seconds.min()} to {time_seconds.max()} seconds")
print(f"Number of data points per run: {len(df)}")

# Add SaveTool to the tools list
tools = 'pan,wheel_zoom,box_zoom,reset,save'

p = figure(title=f"{variable} - {component.upper()} Component",
x_axis_label='Time (s)', y_axis_label=f"{variable.split('.')[-1]} ({component})",
width=800, height=400, tools='pan,wheel_zoom,box_zoom,reset',
width=800, height=400, tools=tools,
sizing_mode="fixed")

component_index = ['x', 'y', 'z'].index(component)
Expand Down Expand Up @@ -147,6 +150,10 @@ def create_plot(self, variable, component, run_numbers=None):
p.on_event('pan_end', self.handle_plot_event)
p.on_event('zoom_end', self.handle_plot_event)

# Customize the SaveTool
save_tool = p.select(type=SaveTool)[0]
save_tool.filename = f"{variable}_{component}_plot"

self.update_status(is_loading=False)
return p

Expand Down

0 comments on commit 6389d80

Please sign in to comment.