Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added option to log time axis in pages/edges #120

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions tsqc/pages/edges.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
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
from ..plot_helpers import filter_points
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)
Expand All @@ -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)
Loading