I have been using p.outer_width in a recent program. Is there a length property for the actual grid lines, p.xgrid and p.ygrid? I would like to measure width and height of a grid square.

It’s not often used, but there is a `cross_bounds`

property for this:

thanks but not finding anything on cross_bounds usage, methods or example.

perhaps p.grid.width or p.grid.height or something like this?

No, there is just `cross_bounds`

as I stated. Like I said, it’s a fairly obscure property (you are the first person to ask about it in years) so adding more docs or examples has never risen much on the priority list.

The ref docs that I linked do state the purpose of the property: “Bounds for the rendered grid lines”, as well as the expected type for the values: `Tuple(Float, Float)`

.

So, something like:

```
xgrid.cross_bounds = (2, 8)
```

will draw the x-grid only between 2 and 8 (along the y-axis) instead of always spanning the entire currently visible plot area. There is no option like “width” or “height” because that’s not enough information to know where to draw (width or height relative to what?)

thanks, good point, relative to what? Perhaps we can do some math based on x1, y1 and x2,y2, so if x1=2 and y1=1 then x2=3 and y2=2, a line drawn thru these coordinates would be the hypoteneuse of rise over run. I am trying to measure the length of the rise and run in pixels. Is there a length property of a line that can do this? So the rise and run will both be lines or maybe rays.

the length of x2-x1 and y2-y1 in pixels or screen units

I’m sorry, I don’t really follow. In any event, `cross_bounds`

is the option that actually exists today.

Maybe I have misunderstood your question. I thought you wanted to *control* the length of grid lines. There is no way to *measure* the length of grid lines. By default they always span the entire viewport. You can get the pixel dimensions of the viewport via `plot.inner_width`

and `plot.inner_height`

but note that these values are *not available until the plot actually renders*, since the exact dimensions depend on e.g how much space the axis or titles or other things take up outside the viewport. You can always read them in a `CustomJS`

callback, or a Python callback, if you are running a Bokeh server app.

cross_bounds is not what I want.

so perhaps with a Rect glyph we can get width and height based on coordinates proposed above, x2-x1 and y2-y1

I’m sorry guess I don’t actually understand what you are trying to do.

ok sorry my bad,

lets assume we have a line segment glyph with x1, y1 and x2,y2 as coordinates. First, can we calculate the length of this segment? Picture the resulting segment as a triangle with the hypoteneuse at a 45 degree angle (the actual line segment) and then a right angle for the remainder of the triangle. Secondly can we somehow measure the rise and run of this triangle?

if there is a length property or way to calculate length then the rise would = y2-y1 and the run would = x2-x1

here is some sample code, when I move the points of the line segment I would like my other 2 lines to move too . When the orange lines change length so should the grid lines

```
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource, PointDrawTool
import math
source = ColumnDataSource(
data = {'x': [1,2], 'y': [2,3],'x1': [2,2],'y1': [2,3],'x2': [1,2],'y2': [2,2]}
)
plot = figure(width=400, height=400)
#plot.line(x, y, color="#FB8072", line_width=2)
#plot.line(x = 'x2', y = 'y2', color="#FB8072", line_width=2, source=source)
plot.line(x = 'x', y = 'y2', color="#FB8072", line_width=2, source=source)
#plot.line(x1, y1, color="#FB8072", line_width=2)
#plot.line(x = 'x1', y = 'y1', color="#FB8072", line_width=2, source=source)
plot.line(x = 'x1', y = 'y', color="#FB8072", line_width=2, source=source)
# add line segment to plot
r_c = plot.scatter(x = 'x', y = 'y', size = 10, fill_color = 'red', line_color = 'black', alpha = 0.7, source = source)
r_l = plot.line(x = 'x', y = 'y', line_color = 'blue', line_width = 3, line_alpha = 0.7, source = source)
#xx=x1-x # error unsuported operand -
#xx=y-x #y is not defined
#console.log(xx)
tool = PointDrawTool(renderers=[r_c], add = False)
plot.add_tools(tool)
plot.toolbar.active_tap = tool
show(plot)
```