top of page

Source Code For Plotting A Basic Dot Graph Using Jupyter Notebooks Using Bokeh (Python 3)

  • Writer: Brian Clark
    Brian Clark
  • Mar 1, 2022
  • 2 min read

I'm working with the Bokeh library and Jupiter notebooks with Anaconda. I wrote a simple circle dot graph for plotting data, and tomorrow, I'm planning a graph using csv data.



#Basic Line Graph 

import bokeh
from bokeh.plotting import figure
from bokeh.io import output_file, show

#prepare some data 
x= [1,2,3,4,5]
y= [6,7,8,9,10]

#prepare the output file 
output_file("Line.html")

#create a figre object
f=figure()

#create Line plot
f.circle(x,y)

show(f)

You can see the different types of graphs that you can use with the Dir() command. In this case, you would use :


dir(f) 
# result : 
['__cached_all__overridden_defaults__',
 '__cached_all__properties__',
 '__cached_all__properties_with_refs__',
 '__class__',
 '__container_props__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__overridden_defaults__',
 '__properties__',
 '__properties_with_refs__',
 '__qualified_model__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__subtype__',
 '__view_model__',
 '__view_module__',
 '__weakref__',
 '_attach_document',
 '_axis',
 '_callbacks',
 '_check_bad_extra_range_name',
 '_check_compatible_scale_and_ranges',
 '_check_fixed_height_policy',
 '_check_fixed_sizing_mode',
 '_check_fixed_width_policy',
 '_check_missing_renderers',
 '_check_required_range',
 '_check_required_scale',
 '_clear_extensions',
 '_clone',
 '_detach_document',
 '_document',
 '_event_callbacks',
 '_grid',
 '_id',
 '_line_stack',
 '_min_preferred_max_height',
 '_min_preferred_max_width',
 '_overridden_defaults',
 '_property_values',
 '_repr_html_',
 '_scale',
 '_scatter',
 '_temp_document',
 '_to_json_like',
 '_trigger_event',
 '_unstable_default_values',
 '_unstable_themed_values',
 '_update_event_callbacks',
 'above',
 'add_glyph',
 'add_layout',
 'add_tile',
 'add_tools',
 'align',
 'annular_wedge',
 'annulus',
 'apply_theme',
 'arc',
 'aspect_ratio',
 'aspect_scale',
 'asterisk',
 'axis',
 'background',
 'background_fill_alpha',
 'background_fill_color',
 'below',
 'bezier',
 'border_fill_alpha',
 'border_fill_color',
 'center',
 'circle',
 'circle_cross',
 'circle_dot',
 'circle_x',
 'circle_y',
 'column',
 'cross',
 'css_classes',
 'dash',
 'dataspecs',
 'dataspecs_with_props',
 'diamond',
 'diamond_cross',
 'diamond_dot',
 'disabled',
 'document',
 'dot',
 'ellipse',
 'equals',
 'extra_x_ranges',
 'extra_y_ranges',
 'frame_height',
 'frame_width',
 'graph',
 'grid',
 'harea',
 'harea_stack',
 'hbar',
 'hbar_stack',
 'height',
 'height_policy',
 'hex',
 'hex_dot',
 'hex_tile',
 'hexbin',
 'hidpi',
 'hline_stack',
 'hover',
 'id',
 'image',
 'image_rgba',
 'image_url',
 'inner_height',
 'inner_width',
 'inverted_triangle',
 'js_event_callbacks',
 'js_link',
 'js_on_change',
 'js_on_event',
 'js_property_callbacks',
 'layout',
 'left',
 'legend',
 'line',
 'lod_factor',
 'lod_interval',
 'lod_threshold',
 'lod_timeout',
 'lookup',
 'margin',
 'match_aspect',
 'max_height',
 'max_width',
 'min_border',
 'min_border_bottom',
 'min_border_left',
 'min_border_right',
 'min_border_top',
 'min_height',
 'min_width',
 'model_class_reverse_map',
 'multi_line',
 'multi_polygons',
 'name',
 'on_change',
 'on_event',
 'outer_height',
 'outer_width',
 'outline_line_alpha',
 'outline_line_cap',
 'outline_line_color',
 'outline_line_dash',
 'outline_line_dash_offset',
 'outline_line_join',
 'outline_line_width',
 'output_backend',
 'oval',
 'patch',
 'patches',
 'plot_height',
 'plot_width',
 'plus',
 'properties',
 'properties_containers',
 'properties_with_refs',
 'properties_with_values',
 'quad',
 'quadratic',
 'query_properties_with_values',
 'ray',
 'rect',
 'ref',
 'references',
 'remove_on_change',
 'renderers',
 'reset_policy',
 'right',
 'row',
 'scatter',
 'segment',
 'select',
 'select_one',
 'set_from_json',
 'set_select',
 'sizing_mode',
 'square',
 'square_cross',
 'square_dot',
 'square_pin',
 'square_x',
 'step',
 'struct',
 'subscribed_events',
 'tags',
 'text',
 'themed_values',
 'title',
 'title_location',
 'to_json',
 'to_json_string',
 'toolbar',
 'toolbar_location',
 'toolbar_sticky',
 'tools',
 'triangle',
 'triangle_dot',
 'triangle_pin',
 'trigger',
 'unapply_theme',
 'update',
 'update_from_json',
 'varea',
 'varea_stack',
 'vbar',
 'vbar_stack',
 'visible',
 'vline_stack',
 'wedge',
 'width',
 'width_policy',
 'x',
 'x_range',
 'x_scale',
 'xaxis',
 'xgrid',
 'y',
 'y_range',
 'y_scale',
 'yaxis',

Change:

#create Line plot
f.circle(x,y)

To the result of your choice :

#create Line plot
f.your_selection_here(x,y)

Comments


bottom of page