Optimize display ranges

This commit is contained in:
usov_i 2023-02-16 18:52:44 +01:00
parent 3293a74017
commit eee9337c72
2 changed files with 12 additions and 30 deletions

View File

@ -19,7 +19,6 @@ from bokeh.models import (
NumericInput, NumericInput,
Panel, Panel,
RadioGroup, RadioGroup,
Range1d,
Select, Select,
Spacer, Spacer,
Spinner, Spinner,
@ -318,8 +317,8 @@ def create():
min_grid_x = -10 min_grid_x = -10
max_grid_x = 10 max_grid_x = 10
min_grid_y = -5 min_grid_y = -10
max_grid_y = 5 max_grid_y = 10
cmap = Dark2[8] cmap = Dark2[8]
syms = ["circle", "inverted_triangle", "square", "diamond", "star", "triangle"] syms = ["circle", "inverted_triangle", "square", "diamond", "star", "triangle"]
@ -389,11 +388,6 @@ def create():
intensity_vec.append(fdata["counts"][ind]) intensity_vec.append(fdata["counts"][ind])
file_flag_vec.append(j) file_flag_vec.append(j)
plot.x_range.start = plot.x_range.reset_start = -2
plot.x_range.end = plot.x_range.reset_end = 5
plot.y_range.start = plot.y_range.reset_start = -4
plot.y_range.end = plot.y_range.reset_end = 3.5
# Plot grid lines # Plot grid lines
xs, ys = [], [] xs, ys = [], []
xs_minor, ys_minor = [], [] xs_minor, ys_minor = [], []
@ -514,13 +508,7 @@ def create():
plot_file = Button(label="Plot selected file(s)", button_type="primary", width=200) plot_file = Button(label="Plot selected file(s)", button_type="primary", width=200)
plot_file.on_click(plot_file_callback) plot_file.on_click(plot_file_callback)
plot = figure( plot = figure(plot_height=550, plot_width=550 + 32, tools="pan,wheel_zoom,reset")
x_range=Range1d(),
y_range=Range1d(),
plot_height=550,
plot_width=550 + 32,
tools="pan,wheel_zoom,reset",
)
plot.toolbar.logo = None plot.toolbar.logo = None
plot.xaxis.visible = False plot.xaxis.visible = False
@ -539,6 +527,9 @@ def create():
source=scatter_source, marker="m", size="s", fill_color="c", line_color="c" source=scatter_source, marker="m", size="s", fill_color="c", line_color="c"
) )
plot.x_range.renderers = [scatter]
plot.y_range.renderers = [scatter]
plot.add_layout(Legend(items=[], location="top_left", click_policy="hide")) plot.add_layout(Legend(items=[], location="top_left", click_policy="hide"))
plot.add_tools(HoverTool(renderers=[scatter], tooltips=[("hkl", "@hkl")])) plot.add_tools(HoverTool(renderers=[scatter], tooltips=[("hkl", "@hkl")]))

View File

@ -15,7 +15,6 @@ from bokeh.models import (
LegendItem, LegendItem,
NumericInput, NumericInput,
RadioGroup, RadioGroup,
Range1d,
Spinner, Spinner,
TextAreaInput, TextAreaInput,
TextInput, TextInput,
@ -38,8 +37,8 @@ class PlotHKL:
min_grid_x = -10 min_grid_x = -10
max_grid_x = 10 max_grid_x = 10
min_grid_y = -5 min_grid_y = -10
max_grid_y = 5 max_grid_y = 10
cmap = Dark2[8] cmap = Dark2[8]
syms = ["circle", "inverted_triangle", "square", "diamond", "star", "triangle"] syms = ["circle", "inverted_triangle", "square", "diamond", "star", "triangle"]
@ -175,11 +174,6 @@ class PlotHKL:
res_vec_x.append(res_x) res_vec_x.append(res_x)
res_vec_y.append(res_y) res_vec_y.append(res_y)
plot.x_range.start = plot.x_range.reset_start = -2
plot.x_range.end = plot.x_range.reset_end = 5
plot.y_range.start = plot.y_range.reset_start = -4
plot.y_range.end = plot.y_range.reset_end = 3.5
# Plot grid lines # Plot grid lines
xs, ys = [], [] xs, ys = [], []
xs_minor, ys_minor = [], [] xs_minor, ys_minor = [], []
@ -353,13 +347,7 @@ class PlotHKL:
plot_file = Button(label="Plot selected file(s)", button_type="primary", width=200) plot_file = Button(label="Plot selected file(s)", button_type="primary", width=200)
plot_file.on_click(plot_file_callback) plot_file.on_click(plot_file_callback)
plot = figure( plot = figure(plot_height=550, plot_width=550 + 32, tools="pan,wheel_zoom,reset")
x_range=Range1d(),
y_range=Range1d(),
plot_height=550,
plot_width=550 + 32,
tools="pan,wheel_zoom,reset",
)
plot.toolbar.logo = None plot.toolbar.logo = None
plot.xaxis.visible = False plot.xaxis.visible = False
@ -389,6 +377,9 @@ class PlotHKL:
source=scatter_source2, size=4, fill_color="green", line_color="green" source=scatter_source2, size=4, fill_color="green", line_color="green"
) )
plot.x_range.renderers = [ellipse, mline, scatter, scatter2]
plot.y_range.renderers = [ellipse, mline, scatter, scatter2]
plot.add_layout(Legend(items=[], location="top_left", click_policy="hide")) plot.add_layout(Legend(items=[], location="top_left", click_policy="hide"))
plot.add_tools(HoverTool(renderers=[scatter, scatter2], tooltips=[("hkl", "@hkl")])) plot.add_tools(HoverTool(renderers=[scatter, scatter2], tooltips=[("hkl", "@hkl")]))