Reader small image

You're reading from  Hands-On Data Visualization with Bokeh

Product typeBook
Published inJun 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789135404
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Kevin Jolly
Kevin Jolly
author image
Kevin Jolly

Kevin Jolly is a formally educated data scientist with a master's degree in data science from the prestigious King's College London. Kevin works as a statistical analyst with a digital healthcare start-up, Connido Limited, in London, where he is primarily involved in leading the data science projects that the company undertakes. He has built machine learning pipelines for small and big data, with a focus on scaling such pipelines into production for the products that the company has built. Kevin is also the author of a book titled Hands-On Data Visualization with Bokeh, published by Packt. He is the editor-in-chief of Linear, a weekly online publication on data science software and products.
Read more about Kevin Jolly

Right arrow

Key concepts and the building blocks of Bokeh

While going through this book, you will come across some terms that are fundamental to understanding the Bokeh package. This section will take you through them.

The following are some key definitions related to Bokeh:

  • Application: The Bokeh application is a rendered Bokeh document that runs in the browser
  • Glyphs: Glyphs are the building blocks of Bokeh, and they are the lines, circles, rectangles, and other shapes that you see on a Bokeh plot
  • Server: The Bokeh server is used to share and publish interactive plots and apps to an audience of your choice
  • Widgets: Widgets in Bokeh are the sliders, drop-down menus, and other small tools that you can embed into your plot to add some interactivity

Plot outputs

There are two methods you can use to render your plot:

  • output_file: This method is used to output your plot as an HTML file and can be used as illustrated in the following code:
output_file('plot.html')
  • output_notebook: This is used to output your plot in the Jupyter Notebook you are presently working on and can be used as illustrated in the following code:
output_notebook()

Interfaces:

The first step to understanding interfaces is to understand what a class and a method are. Think of a class as a vessel that holds different types of cookie together. The vessel in this case is the class and the cookies are the methods that give the vessel some functionality, in our case, as a container for the cookies.

Since Python is an object-oriented programming language, it uses classes to group different objects that it creates together.

A class by itself is useless unless it has some functionality associated with it. These functionalities are provided to classes by methods.

Bokeh provides a mid-level plotting interface, similar to that of matplotlib , which is known as bokeh.plotting. The main class in the bokeh.plotting interface is the Figure class, which includes methods for adding different kinds of glyphs to a plot.

A user can create a Figure object by using the figure function, as illustrated in the following code:

from bokeh.plotting import figure

# create a Figure object
p = figure(plot_width=500, plot_height=400, tools="pan,hover")

In Bokeh, the figure function, as illustrated in the preceding code, is used to initialize and store the contents of your plot. The variable p in the preceding code now holds information about the plot, including its height, width, and the kind of tools the plot will use. Since figure is our main class, methods such as line, circle, and so on can be added to our diagram in order to create the plot.

Previous PageNext Page
You have been reading a chapter from
Hands-On Data Visualization with Bokeh
Published in: Jun 2018Publisher: PacktISBN-13: 9781789135404
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Kevin Jolly

Kevin Jolly is a formally educated data scientist with a master's degree in data science from the prestigious King's College London. Kevin works as a statistical analyst with a digital healthcare start-up, Connido Limited, in London, where he is primarily involved in leading the data science projects that the company undertakes. He has built machine learning pipelines for small and big data, with a focus on scaling such pipelines into production for the products that the company has built. Kevin is also the author of a book titled Hands-On Data Visualization with Bokeh, published by Packt. He is the editor-in-chief of Linear, a weekly online publication on data science software and products.
Read more about Kevin Jolly