- Bokeh - Discussion
- Bokeh - Useful Resources
- Bokeh - Quick Guide
- Bokeh - Developing with JavaScript
- Bokeh - WebGL
- Bokeh - Extending Bokeh
- Bokeh - Embedding Plots and Apps
- Bokeh - Exporting Plots
- Bokeh - Using Bokeh Subcommands
- Bokeh - Server
- Bokeh - Adding Widgets
- Bokeh - Customising legends
- Bokeh - Styling Visual Attributes
- Bokeh - Plot Tools
- Bokeh - Layouts
- Bokeh - Filtering Data
- Bokeh - ColumnDataSource
- Bokeh - Pandas
- Bokeh - Annotations and Legends
- Bokeh - Axes
- Bokeh - Setting Ranges
- Bokeh - Specialized Curves
- Bokeh - Wedges and Arcs
- Bokeh - Rectangle, Oval and Polygon
- Bokeh - Circle Glyphs
- Bokeh - Area Plots
- Bokeh - Plots with Glyphs
- Bokeh - Basic Concepts
- Bokeh - Jupyter Notebook
- Bokeh - Getting Started
- Bokeh - Environment Setup
- Bokeh - Introduction
- Bokeh - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Bokeh - ColumnDataSource
Most of the plotting methods in Bokeh API are able to receive data source parameters through ColumnDatasource object. It makes sharing data between plots and ‘DataTables’.
A ColumnDatasource can be considered as a mapping between column name and pst of data. A Python dict object with one or more string keys and psts or numpy arrays as values is passed to ColumnDataSource constructor.
Example
Below is the example
from bokeh.models import ColumnDataSource data = { x :[1, 4, 3, 2, 5], y :[6, 5, 2, 4, 7]} cds = ColumnDataSource(data = data)
This object is then used as value of source property in a glyph method. Following code generates a scatter plot using ColumnDataSource.
from bokeh.plotting import figure, output_file, show from bokeh.models import ColumnDataSource data = { x :[1, 4, 3, 2, 5], y :[6, 5, 2, 4, 7]} cds = ColumnDataSource(data = data) fig = figure() fig.scatter(x = x , y = y ,source = cds, marker = "circle", size = 20, fill_color = "grey") show(fig)
Output
Instead of assigning a Python dictionary to ColumnDataSource, we can use a Pandas DataFrame for it.
Let us use ‘test.csv’ (used earper in this section) to obtain a DataFrame and use it for getting ColumnDataSource and rendering pne plot.
from bokeh.plotting import figure, output_file, show import pandas as pd from bokeh.models import ColumnDataSource df = pd.read_csv( test.csv ) cds = ColumnDataSource(df) fig = figure(y_axis_type = log ) fig.pne(x = x , y = pow ,source = cds, pne_color = "grey") show(fig)