From 72fd54d268f06a7446e59adb213fc8679be1102e Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Wed, 4 May 2022 17:20:24 +0200 Subject: [PATCH] Add legend items for propagation vectors --- pyzebra/app/panel_ccl_prepare.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyzebra/app/panel_ccl_prepare.py b/pyzebra/app/panel_ccl_prepare.py index 751d455..911ed49 100644 --- a/pyzebra/app/panel_ccl_prepare.py +++ b/pyzebra/app/panel_ccl_prepare.py @@ -657,13 +657,20 @@ def create(): text=["h", "k"], ) - # Generate legend for different file entries (symbol) + # Legend items for different file entries (symbol) legend_items = [] if not res_flag and file_flag: labels, inds = np.unique(scan_source.data["l"], return_index=True) for label, ind in zip(labels, inds): legend_items.append(LegendItem(label=label, renderers=[scatter], index=ind)) + # Legend items for propagation vector (color) + if prop_legend_flag: + labels, inds = np.unique(scan_source.data["c"], return_index=True) + for label, ind in zip(labels, inds): + label = f"k={k[cmap.index(label)]}" + legend_items.append(LegendItem(label=label, renderers=[mline], index=ind)) + plot.legend.items = legend_items plot_file = Button(label="Plot selected file(s)", button_type="primary", width=200) @@ -697,7 +704,7 @@ def create(): ) scan_source = ColumnDataSource(dict(xs=[], ys=[], x=[], y=[], m=[], s=[], c=[], l=[])) - plot.add_glyph(scan_source, MultiLine(xs="xs", ys="ys", line_color="c")) + mline = plot.add_glyph(scan_source, MultiLine(xs="xs", ys="ys", line_color="c")) scatter = plot.add_glyph( scan_source, Scatter(x="x", y="y", marker="m", size="s", fill_color="c", line_color="c") )