Bokeh
pytao.plotting.bokeh
Classes
pytao.plotting.bokeh.BokehAppCreator
BokehAppCreator(manager, graphs, share_x=None, include_variables=False, grid=None, width=None, height=None, include_layout=False, graph_sizing_mode=None, layout_height=None, xlim=None, ylim=None, ix_uni=None)
A composite Bokeh application creator made up of 1 or more graphs.
This can be used to: * Generate a static HTML page without Python widgets * Generate a Notebook (or standalone) application with Python widgets
Interactive widgets will use the Tao object to adjust variables during
callbacks resulting from user interaction.
Source code in pytao/plotting/bokeh.py
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 | |
Methods:
create_state()
Create an independent application state based on the graph data.
Source code in pytao/plotting/bokeh.py
1496 1497 1498 1499 1500 1501 1502 1503 1504 | |
pytao.plotting.bokeh.BokehGraphManager
BokehGraphManager(tao)
Bases: GraphManager
Bokeh backend graph manager - for non-Jupyter contexts.
Source code in pytao/plotting/plot.py
1406 1407 1408 1409 | |
Methods:
plot(template, *, region_name=None, include_layout=True, sizing_mode=None, width=None, height=None, layout_height=None, share_x=None, xlim=None, ylim=None, save=None, curves=None, settings=None, ix_uni=None)
Plot a graph with Bokeh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Graph template name. |
required |
region_name
|
str
|
Graph region name. |
None
|
include_layout
|
bool
|
Include a layout plot at the bottom, if not already placed and if appropriate (i.e., another plot uses longitudinal coordinates on the x-axis). |
True
|
sizing_mode
|
Optional[SizingModeType]
|
Set the sizing mode for all graphs. Default is configured on a per-graph basis, typically "inherit". |
None
|
width
|
int
|
Width of each plot. |
None
|
height
|
int
|
Height of each plot. |
None
|
layout_height
|
int
|
Height of the layout plot. |
None
|
share_x
|
bool or None
|
Share x-axes where sensible ( |
None
|
xlim
|
(float, float)
|
X axis limits. |
None
|
ylim
|
(float, float)
|
Y axis limits. |
None
|
curves
|
Dict[int, TaoCurveSettings]
|
Dictionary of curve index to curve settings. These settings will be applied to the placed graph prior to plotting. |
None
|
settings
|
TaoGraphSettings
|
Graph customization settings. |
None
|
save
|
str or bool
|
Save the plot to a static HTML file with the given name.
If |
None
|
ix_uni
|
int
|
Plot data from this universe. |
None
|
Returns:
| Type | Description |
|---|---|
list of graphs
|
|
BokehAppCreator
|
|
Source code in pytao/plotting/bokeh.py
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 | |
plot_ele_methods(data, *, columns=None, show_names=True, show_csr_ds_step=None, include_layout=True, lane_height=0.8, width=None, height=None, layout_height=None, save=None)
Plot element method settings as categorical lanes along the beamline.
Each method (e.g., tracking_method) becomes a horizontal lane, with
each element drawn as a block spanning its longitudinal extent, colored
by the method value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ElementMethodsPlotData
|
Per-element method data, gathered via
|
required |
columns
|
sequence of str
|
Method columns to plot, in order. Defaults to all categorical columns with data for the selected elements. |
None
|
show_names
|
bool
|
Label method transitions with the element names before and after the transition point. |
True
|
show_csr_ds_step
|
bool
|
Add a subplot of |
None
|
include_layout
|
bool
|
Include a lattice layout plot at the bottom. |
True
|
lane_height
|
float
|
Height of each lane's blocks, where lanes are spaced 1.0 apart. |
0.8
|
width
|
int
|
Width of each plot in pixels. |
None
|
height
|
int
|
Height of the lane plot in pixels. Defaults to scaling with the number of lanes. |
None
|
layout_height
|
int
|
Height of the layout plot in pixels. |
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
Returns:
| Type | Description |
|---|---|
ElementMethodsPlotData
|
|
column
|
|
Source code in pytao/plotting/bokeh.py
2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 | |
plot_field(ele_id, *, colormap=None, radius=0.015, num_points=100, x_scale=1.0, width=None, height=None, save=None)
Plot field information for a given element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ele_id
|
str
|
Element ID. |
required |
colormap
|
str
|
Colormap for the plot. Matplotlib defaults to "PRGn_r", and bokeh defaults to "". |
None
|
radius
|
float
|
Radius. |
0.015
|
num_points
|
int
|
Number of data points. |
100
|
width
|
int
|
|
None
|
height
|
int
|
|
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
Returns:
| Type | Description |
|---|---|
ElementField
|
|
figure
|
|
Source code in pytao/plotting/bokeh.py
2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 | |
plot_grid(templates, grid, *, include_layout=False, share_x=None, width=None, height=None, figsize=None, layout_height=None, xlim=None, ylim=None, curves=None, settings=None, save=None, ix_uni=None)
Plot graphs on a grid with Bokeh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
templates
|
list of str
|
Graph template names. |
required |
grid
|
(nrows, ncols)
|
Grid the provided graphs into this many rows and columns. |
required |
include_layout
|
bool
|
Include a layout plot at the bottom of each column. |
False
|
share_x
|
bool or None
|
Share x-axes where sensible ( |
None
|
figsize
|
(int, int)
|
Figure size. Alternative to specifying |
None
|
width
|
int
|
Width of the whole plot. |
None
|
height
|
int
|
Height of the whole plot. |
None
|
layout_height
|
int
|
Height of the layout plot. |
None
|
xlim
|
list of (float, float)
|
X axis limits for each graph. |
None
|
ylim
|
list of (float, float)
|
Y axis limits for each graph. |
None
|
curves
|
list of Dict[int, TaoCurveSettings]
|
One dictionary per graph, with each dictionary mapping the curve index to curve settings. These settings will be applied to the placed graphs prior to plotting. |
None
|
settings
|
list of TaoGraphSettings
|
Graph customization settings, per graph. |
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
ix_uni
|
int
|
Plot data from this universe for every graph in the grid. |
None
|
Returns:
| Type | Description |
|---|---|
list of graphs
|
|
BokehAppCreator
|
|
Source code in pytao/plotting/bokeh.py
2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 | |
to_bokeh_graph(graph)
Create a Bokeh graph instance from the backend-agnostic AnyGraph version.
For example, BasicGraph becomes BokehBasicGraph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
AnyGraph
|
|
required |
Returns:
| Type | Description |
|---|---|
AnyBokehGraph
|
|
Source code in pytao/plotting/bokeh.py
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 | |
pytao.plotting.bokeh.NotebookGraphManager
NotebookGraphManager(tao)
Bases: BokehGraphManager
Jupyter notebook Bokeh backend graph manager.
Source code in pytao/plotting/plot.py
1406 1407 1408 1409 | |
Methods:
plot(template, *, region_name=None, include_layout=True, sizing_mode=None, width=None, height=None, layout_height=None, share_x=None, vars=False, xlim=None, ylim=None, notebook_handle=False, save=None, curves=None, settings=None, ix_uni=None)
Plot a graph with Bokeh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Graph template name. |
required |
region_name
|
str
|
Graph region name. |
None
|
include_layout
|
bool
|
Include a layout plot at the bottom, if not already placed and if appropriate (i.e., another plot uses longitudinal coordinates on the x-axis). |
True
|
sizing_mode
|
Optional[SizingModeType]
|
Set the sizing mode for all graphs. Default is configured on a per-graph basis, typically "inherit". |
None
|
width
|
int
|
Width of each plot. |
None
|
height
|
int
|
Height of each plot. |
None
|
layout_height
|
int
|
Height of the layout plot. |
None
|
share_x
|
bool or None
|
Share x-axes where sensible ( |
None
|
vars
|
bool
|
Show Tao variables as adjustable widgets, like "single mode". |
False
|
xlim
|
(float, float)
|
X axis limits. |
None
|
ylim
|
(float, float)
|
Y axis limits. |
None
|
curves
|
Dict[int, TaoCurveSettings]
|
Dictionary of curve index to curve settings. These settings will be applied to the placed graph prior to plotting. |
None
|
settings
|
TaoGraphSettings
|
Graph customization settings. |
None
|
save
|
str or bool
|
Save the plot to a static HTML file with the given name.
If |
None
|
ix_uni
|
int
|
Plot data from this universe. |
None
|
Returns:
| Type | Description |
|---|---|
BokehAppCreator
|
|
Source code in pytao/plotting/bokeh.py
2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 | |
plot_field(ele_id, *, colormap=None, radius=0.015, num_points=100, width=None, height=None, x_scale=1.0, save=None)
Plot field information for a given element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ele_id
|
str
|
Element ID. |
required |
colormap
|
str
|
Colormap for the plot. Matplotlib defaults to "PRGn_r", and bokeh defaults to "". |
None
|
radius
|
float
|
Radius. |
0.015
|
num_points
|
int
|
Number of data points. |
100
|
width
|
int
|
|
None
|
height
|
int
|
|
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
Source code in pytao/plotting/bokeh.py
2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 | |
plot_grid(templates, grid, *, curves=None, settings=None, include_layout=False, share_x=None, vars=False, figsize=None, layout_height=None, xlim=None, ylim=None, width=None, height=None, save=None, ix_uni=None)
Plot graphs on a grid with Bokeh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
templates
|
list of str
|
Graph template names. |
required |
grid
|
(nrows, ncols)
|
Grid the provided graphs into this many rows and columns. |
required |
include_layout
|
bool
|
Include a layout plot at the bottom of each column. |
False
|
share_x
|
bool or None
|
Share x-axes where sensible ( |
None
|
vars
|
bool
|
Show Tao variables as adjustable widgets, like "single mode". |
False
|
figsize
|
(int, int)
|
Figure size. Alternative to specifying |
None
|
width
|
int
|
Width of the whole plot. |
None
|
height
|
int
|
Height of the whole plot. |
None
|
layout_height
|
int
|
Height of the layout plot. |
None
|
xlim
|
list of (float, float)
|
X axis limits for each graph. |
None
|
ylim
|
list of (float, float)
|
Y axis limits for each graph. |
None
|
curves
|
list of Dict[int, TaoCurveSettings]
|
One dictionary per graph, with each dictionary mapping the curve index to curve settings. These settings will be applied to the placed graphs prior to plotting. |
None
|
settings
|
list of TaoGraphSettings
|
Graph customization settings, per graph. |
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
ix_uni
|
int
|
Plot data from this universe for every graph in the grid. |
None
|
Returns:
| Type | Description |
|---|---|
list of graphs
|
|
BokehAppCreator
|
|
Source code in pytao/plotting/bokeh.py
2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 | |
Functions:
pytao.plotting.bokeh.floor_plan_figure
floor_plan_figure(elements, *, tools=None, toolbar_location='above', title='', x_axis_label='', y_axis_label='', sizing_mode='inherit', width=None, height=None, line_width_scale=None, annotate_elements=None)
Create a figure of floor plan elements, as Tao draws a floor_plan graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
sequence of FloorPlanElement
|
|
required |
tools
|
str
|
Bokeh tools string. Defaults to the floor plan tools setting. |
None
|
toolbar_location
|
str
|
|
"above"
|
title
|
str
|
|
""
|
x_axis_label
|
str
|
|
""
|
y_axis_label
|
str
|
|
""
|
sizing_mode
|
SizingModeType
|
|
"inherit"
|
width
|
int
|
|
None
|
height
|
int
|
|
None
|
line_width_scale
|
float
|
|
None
|
annotate_elements
|
bool
|
Draw element name labels. Defaults to the floor plan annotation setting. |
None
|
Returns:
| Type | Description |
|---|---|
figure
|
|
Source code in pytao/plotting/bokeh.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | |
pytao.plotting.bokeh.lat_layout_figure
lat_layout_figure(elements, *, tools=None, toolbar_location='above', title='', x_axis_label='', sizing_mode='inherit', aspect_ratio=None, width=None, height=None, line_width_scale=None)
Create a figure of lattice layout elements, as Tao draws a lat_layout graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
sequence of LatticeLayoutElement
|
|
required |
tools
|
str
|
Bokeh tools string. Defaults to the lattice layout tools setting. |
None
|
toolbar_location
|
str
|
|
"above"
|
title
|
str
|
|
""
|
x_axis_label
|
str
|
|
""
|
sizing_mode
|
SizingModeType
|
|
"inherit"
|
aspect_ratio
|
float
|
Width / height. |
None
|
width
|
int
|
|
None
|
height
|
int
|
|
None
|
line_width_scale
|
float
|
|
None
|
Returns:
| Type | Description |
|---|---|
figure
|
|
Source code in pytao/plotting/bokeh.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 | |
pytao.plotting.bokeh.set_defaults
set_defaults(width=None, height=None, stacked_height=None, layout_height=None, palette=None, show_bokeh_logo=None, tools=None, grid_toolbar_location=None, lattice_layout_tools=None, floor_plan_tools=None, floor_plan_annotate_elements=None, layout_font_size=None, floor_plan_font_size=None, limit_scale_factor=None, max_data_points=None, variables_per_row=None, show_sliders=None, line_width_scale=None, floor_line_width_scale=None, resources=None)
Change defaults used for Bokeh plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Plot default width. |
None
|
height
|
int
|
Plot default height. |
None
|
stacked_height
|
int
|
Stacked plot default height ( |
None
|
layout_height
|
int
|
Layout plot height. |
None
|
palette
|
str
|
Palette for |
None
|
show_bokeh_logo
|
bool
|
Show Bokeh logo on each plot. |
None
|
tools
|
str
|
Bokeh tools to use. |
"pan,wheel_zoom,box_zoom,reset,hover,crosshair"
|
grid_toolbar_location
|
str
|
Toolbar location for gridded plots. |
"right"
|
lattice_layout_tools
|
str
|
Bokeh tools to use specifically for lattice layouts. |
None
|
floor_plan_tools
|
str
|
Bokeh tools to use specifically for floor plan layouts. |
None
|
layout_font_size
|
str
|
Font size to use in lattice layouts. |
None
|
floor_plan_font_size
|
str
|
Font size to use in floor plan layouts. |
None
|
limit_scale_factor
|
float
|
View limits from Tao are scaled by this factor. This can be used to ensure that all data is visible despite drawing method differences. |
1.01
|
max_data_points
|
int
|
Maximum number of data points to show in the slider. |
None
|
variables_per_row
|
int
|
Variables to list per row when in single mode (i.e., |
2
|
show_sliders
|
bool
|
Show sliders alongside the spinners in single mode. |
True
|
line_width_scale
|
float
|
Plot line width scaling factor applied to Tao's line width. |
1.0
|
floor_line_width_scale
|
float
|
Floor plan line width scaling factor applied to Tao's line width. |
0.5
|
resources
|
'cdn' or 'inline'
|
When saving Bokeh plots to HTML, make the file fully standalone ("inline") by saving everything necessary to load the page in the file, or retrieve shared scripts and resources from online ("cdn") when the page is opened. |
None
|
Source code in pytao/plotting/bokeh.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |