Parameter desired_num_ticks is ignored for ColorBar ticker

Hello.

I’m having strange issue trying to create a legend for a heatmap.
I was using https://bokeh.pydata.org/en/latest/docs/gallery/unemployment.html as an template/example. Heatmap works fine, but ticks for ColorBar I’m using as a legend are not behaving.
Code:

p = figure(x_axis_type=“datetime”, x_range=(0, 10), y_range=[0, 10],
tools=‘hover, box_zoom, reset, save’, width=600, height=600, title=‘Title’)
mapper = LinearColorMapper(palette=RdYlGn10, low=0, high=300)
color_bar = ColorBar(color_mapper=mapper, location=(0, 0),
ticker=BasicTicker(desired_num_ticks=len(RdYlGn10), num_minor_ticks=0),
formatter=NumeralTickFormatter(format=“0,0”))
p.add_layout(color_bar, ‘right’)

output_notebook()
show(p)

Expected results: color bar with 10 cells (from palette RdYlGn10) and 10 ticks, one for each cell.

Actual results: 7 ticks on ticker. And if I change ‘high’ value for LinearColorMapper to let’s say 200, I’m getting 11 ticks. For 150 - 7 ticks. Looks like ‘desired_num_ticks’ parameter being completely ignored.

Question: is that a defect?
Thanks!

Hi,

desired_num_ticks is only a suggestion, the ticker spacing algorithm may override it. If you have a very explicit set of ticks you want to see, you are better advised to use a fixed ticker:
  
  https://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#fixedticker

Thanks,

Bryan

···

On May 9, 2018, at 13:10, al[email protected] wrote:

Hello.

I'm having strange issue trying to create a legend for a heatmap.
I was using https://bokeh.pydata.org/en/latest/docs/gallery/unemployment.html as an template/example. Heatmap works fine, but ticks for ColorBar I'm using as a legend are not behaving.
Code:

    p = figure(x_axis_type="datetime", x_range=(0, 10), y_range=[0, 10],
               tools='hover, box_zoom, reset, save', width=600, height=600, title='Title')
    mapper = LinearColorMapper(palette=RdYlGn10, low=0, high=300)
    color_bar = ColorBar(color_mapper=mapper, location=(0, 0),
                         ticker=BasicTicker(desired_num_ticks=len(RdYlGn10), num_minor_ticks=0),
                         formatter=NumeralTickFormatter(format="0,0"))
    p.add_layout(color_bar, 'right')

    output_notebook()
    show(p)

Expected results: color bar with 10 cells (from palette RdYlGn10) and 10 ticks, one for each cell.

Actual results: 7 ticks on ticker. And if I change 'high' value for LinearColorMapper to let's say 200, I'm getting 11 ticks. For 150 - 7 ticks. Looks like 'desired_num_ticks' parameter being completely ignored.

Question: is that a defect?
Thanks!

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9d9b6a01-d8ea-4b48-a2a0-668d1d7e25fc%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.