How to limit the number of minor lines in Grid

How i can limit these minor lines to 1 line in center rather than 4 lines ?

@msiawa

The axes and (optionally grids) have tickers described here in the documentation.https://docs.bokeh.org/en/latest/docs/reference/models/tickers.html#bokeh.models.tickers.Ticker

Some of the tickers use the num_minor_ticks property, which sets the number of minor ticks between major ticks.

Here’s a small illustrative example customizing the minor ticks for the x-axis.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
import numpy as np

from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource

x = np.linspace(0.0,1.0,1001)
y = np.sin(2.0*np.pi*x)

data = dict(x=x, y=y)

p = figure(width=500, height=500)

p.xaxis.ticker.num_minor_ticks = 2

p.xgrid.minor_grid_line_color = p.xgrid.grid_line_color
p.xgrid.minor_grid_line_dash = 'dotted'

ln = p.line(x='x', y='y', source=ColumnDataSource(data=data))


show(p)
1 Like