from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, Range1d, Label

output_file("label.html", title="label.py example")

source = ColumnDataSource(data=dict(height=[66, 71, 72, 68, 58, 62],
                                    weight=[165, 189, 220, 141, 260, 174],
                                    names=['Mark', 'Amir', 'Matt', 'Greg',
                                           'Owen', 'Juan']))

p = figure(title='Dist. of 10th Grade Students at Lee High',
           x_range=Range1d(140, 275))
p.scatter(x='weight', y='height', size=8, source=source)
p.xaxis[0].axis_label = 'Weight (lbs)'
p.yaxis[0].axis_label = 'Height (in)'

label = Label(x='weight', y='height', text='names', level='glyph',
              x_offset=5, y_offset=-5, source=source)
p.add_annotation(label)

show(p)

from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, Range1d, Label

output_file("label.html", title="label.py example")

source = ColumnDataSource(data=dict(height=[66, 71, 72, 68, 58, 62],
                                    weight=[165, 189, 220, 141, 260, 174],
                                    names=['Mark', 'Amir', 'Matt', 'Greg',
                                           'Owen', 'Juan']))

p = figure(title='Dist. of 10th Grade Students at Lee High',
           x_range=Range1d(140, 275))
p.scatter(x='weight', y='height', size=8, source=source)
p.xaxis[0].axis_label = 'Weight (lbs)'
p.yaxis[0].axis_label = 'Height (in)'

labels = Label(x='weight', y='height', text='names', level='glyph',
              x_offset=5, y_offset=-5, source=source, render_mode='canvas')

citation = Label(x=70, y=70, x_units='screen', y_units='screen',
                 text=['Collected by Luke C. 2016-04-01'], render_mode='css',
                 border_line_color='black', border_line_alpha=1.0,
                 background_fill_color='white', background_fill_alpha=1.0)

p.add_annotation(labels)
p.add_annotation(citation)

show(p)

Include example of css render_mode
Include example of css render_mode

  from bokeh.plotting import figure, show, output_file
  from bokeh.models import ColumnDataSource, Range1d, Label
  
  output_file("label.html", title="label.py example")
  
  source = ColumnDataSource(data=dict(height=[66, 71, 72, 68, 58, 62],
                                      weight=[165, 189, 220, 141, 260, 174],
                                      names=['Mark', 'Amir', 'Matt', 'Greg',
                                             'Owen', 'Juan']))
  
  p = figure(title='Dist. of 10th Grade Students at Lee High',
             x_range=Range1d(140, 275))
  p.scatter(x='weight', y='height', size=8, source=source)
  p.xaxis[0].axis_label = 'Weight (lbs)'
  p.yaxis[0].axis_label = 'Height (in)'
  
- label = Label(x='weight', y='height', text='names', level='glyph',
+ labels = Label(x='weight', y='height', text='names', level='glyph',
-               x_offset=5, y_offset=-5, source=source)
+               x_offset=5, y_offset=-5, source=source, render_mode='canvas')
+ 
+ citation = Label(x=70, y=70, x_units='screen', y_units='screen',
+                  text=['Collected by Luke C. 2016-04-01'], render_mode='css',
+                  border_line_color='black', border_line_alpha=1.0,
+                  background_fill_color='white', background_fill_alpha=1.0)
+ 
- p.add_annotation(label)
+ p.add_annotation(labels)
+ p.add_annotation(citation)
  
  show(p)
  
Include example of css render_mode
## Code Before:
from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, Range1d, Label

output_file("label.html", title="label.py example")

source = ColumnDataSource(data=dict(height=[66, 71, 72, 68, 58, 62],
                                    weight=[165, 189, 220, 141, 260, 174],
                                    names=['Mark', 'Amir', 'Matt', 'Greg',
                                           'Owen', 'Juan']))

p = figure(title='Dist. of 10th Grade Students at Lee High',
           x_range=Range1d(140, 275))
p.scatter(x='weight', y='height', size=8, source=source)
p.xaxis[0].axis_label = 'Weight (lbs)'
p.yaxis[0].axis_label = 'Height (in)'

label = Label(x='weight', y='height', text='names', level='glyph',
              x_offset=5, y_offset=-5, source=source)
p.add_annotation(label)

show(p)

## Instruction:
Include example of css render_mode
## Code After:
from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, Range1d, Label

output_file("label.html", title="label.py example")

source = ColumnDataSource(data=dict(height=[66, 71, 72, 68, 58, 62],
                                    weight=[165, 189, 220, 141, 260, 174],
                                    names=['Mark', 'Amir', 'Matt', 'Greg',
                                           'Owen', 'Juan']))

p = figure(title='Dist. of 10th Grade Students at Lee High',
           x_range=Range1d(140, 275))
p.scatter(x='weight', y='height', size=8, source=source)
p.xaxis[0].axis_label = 'Weight (lbs)'
p.yaxis[0].axis_label = 'Height (in)'

labels = Label(x='weight', y='height', text='names', level='glyph',
              x_offset=5, y_offset=-5, source=source, render_mode='canvas')

citation = Label(x=70, y=70, x_units='screen', y_units='screen',
                 text=['Collected by Luke C. 2016-04-01'], render_mode='css',
                 border_line_color='black', border_line_alpha=1.0,
                 background_fill_color='white', background_fill_alpha=1.0)

p.add_annotation(labels)
p.add_annotation(citation)

show(p)
