miranov25 / RootInteractive

5 stars 12 forks source link

Box around each bin in 2D histograms (heatmap) #209

Open bulukutlu opened 2 years ago

bulukutlu commented 2 years ago

Hi,

In figures with 2D histograms drawn using the heatmap option (standard), each bin is surrounded by a black line (box). It can obstruct the view of the bin content/color when there are many bins in the figure. It would be great if there was an option to disable this box.

From what I can see one way of disabling this would be to set the line_width of the Quads like so: histoGlyph = Quad(left="bin_bottom_0", right="bin_top_0", bottom="bin_bottom_1", top="bin_top_1", fill_color=mapperC, line_width=0) in RootInteractive/InteractiveDrawing/bokeh/bokehTools.py on line 1110. Setting them to zero makes the box disappear.

Cheers, Berkin

bulukutlu commented 2 years ago

I have also changed some other options for drawing 2D histograms with "heatmap" in my RootInteractive fork. Would be great if these changes could be parametrized as drawing options:

Setting thickness of the box around glyphs (quads):

Setting to zero as here disables the box entirely:

histoGlyph = Quad(left="bin_bottom_0", right="bin_top_0", bottom="bin_bottom_1", top="bin_top_1",
                          fill_color=mapperC, line_width=0)

Using logarithmic scale for color axis

This can be achieved by using a LogColorMapper (I didn't test what happens if bin_count is negative, it might break)

mapperC = {"field": "bin_count", "transform": LogColorMapper(palette=options['palette'])}

Not displaying empty pads

It would be great if we had the option not to draw empty pads at all. Especially crucial for some plots we have in TPC QC where without this it is impossible to see the shape of the distribution. This can be done by using the low options on the color mappers and setting the colors of low values to (255,255,255,0.0) with alpha=0.

mapperC = {"field": "bin_count", "transform": LogColorMapper(palette=options['palette'],low=1,low_color=(255,255,255,0.0))}