Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Bokeh's 'screen units'?

Tags:

bokeh

In Bokeh, what are 'screen units'?

The web isn't forthright on what these creatures are and I've had no luck gleaning their meaning from the (0.9.3) source code

The Bokeh source uses them in its examples, such as this from bokeh/_glyph_functions.py for 'rect':

from bokeh.plotting import figure, output_file, show

plot = figure(width=300, height=300)
plot.rect(x=[1, 2, 3], y=[1, 2, 3], width=10, height=20, color="#CAB2D6",
          width_units="screen", height_units="screen")
show(plot)

but I don't see them defined anywhere. What other options would 'width_units' support?

like image 866
JS. Avatar asked Sep 09 '15 17:09

JS.


1 Answers

Bokeh lets users set renderer locations either by screen units (related to the pixel distance from the origin of the plot) or data units (which uses the mapper that is used to calculate the plot ranges based on the input data)

This helps in cases like adding box annotations, where sometimes you want the box to be linked to screen (perhaps always in the middle of the screen) or linked to data values (having a box at x=10)

The docs: https://github.com/bokeh/bokeh/blob/master/bokeh/enums.py#L46

like image 149
Luke Canavan Avatar answered Oct 14 '22 20:10

Luke Canavan