From 795aa3a4efedfcb85e5bb891dbc322791422c9d7 Mon Sep 17 00:00:00 2001 From: Savita Karthikeyan Date: Sun, 28 Jan 2024 18:49:51 +0000 Subject: [PATCH] added option to log time axis in pages/edges better y-axis label Closes issue #104 Partially addresses #105 --- tsqc/pages/edges.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tsqc/pages/edges.py b/tsqc/pages/edges.py index a306199..3933dc5 100644 --- a/tsqc/pages/edges.py +++ b/tsqc/pages/edges.py @@ -1,6 +1,7 @@ import bokeh.models as bkm import holoviews as hv import holoviews.operation.datashader as hd +import numpy as np import panel as pn from .. import config @@ -8,13 +9,19 @@ from ..plot_helpers import hover_points -def page(tsm): - hv.extension("bokeh") +def make_edges_panel(log_y, tsm): edges_df = tsm.edges_df - edges_df["parent_time_right"] = edges_df["parent_time"] - lines = hv.Segments( - edges_df, kdims=["left", "parent_time", "right", "parent_time_right"] - ) + if log_y: + edges_df["log_parent_time"] = np.log10(1 + edges_df["parent_time"]) + edges_df["log_parent_time_right"] = edges_df["log_parent_time"] + y_dim_left = "log_parent_time" + y_dim_right = "log_parent_time_right" + else: + edges_df["parent_time_right"] = edges_df["parent_time"] + y_dim_left = "parent_time" + y_dim_right = "parent_time_right" + + lines = hv.Segments(edges_df, kdims=["left", y_dim_left, "right", y_dim_right]) range_stream = hv.streams.RangeXY(source=lines) streams = [range_stream] filtered = lines.apply(filter_points, streams=streams) @@ -34,8 +41,19 @@ def page(tsm): width=config.PLOT_WIDTH, height=config.PLOT_HEIGHT, xlabel="Position", - ylabel="Time", + ylabel="Time (parent node)", ) ) - return pn.Column(main) + + +def page(tsm): + hv.extension("bokeh") + + log_y_checkbox = pn.widgets.Checkbox(name="Log y-axis", value=False) + plot_options = pn.Column( + pn.pane.Markdown("### Plot Options"), + log_y_checkbox, + ) + edges_panel = pn.bind(make_edges_panel, log_y=log_y_checkbox, tsm=tsm) + return pn.Column(plot_options, edges_panel)