Bokeh – Using Subcommands

Bokeh - Using Subcommands

In this chapter, we will discuss Bokeh Using Bokeh Subcommands. The Bokeh application provides a number of subcommands to be executed from the command line. The following table shows the subcommands โˆ’

1HtmlCreate HTML files for one or more applications
2infoprint information of Bokeh server configuration
3JSONCreate JSON files for one or more applications
4pngCreate PNG files for one or more applications
5sample dataDownload the bokeh sample data sets
6secretCreate a Bokeh secret key for use with the Bokeh server
7serveRun a Bokeh server hosting one or more applications
8staticServe static assets (JavaScript, CSS, images, fonts, etc.) used by the BokeJS library
9SVGCreate SVG files for one or more applications

The following command generates an HTML file for a Python script having a Bokeh figure.

C:\python37>bokeh html -o app.html app.py

Adding the show option automatically opens the HTML file in a browser. Likewise, the Python script is converted to PNG, SVG, JSON files with the corresponding subcommand.

To display information of Bokeh server, use info subcommand as follows โˆ’

C:\python37>bokeh info
Python version : 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
IPython version : (not installed)
Tornado version : 6.0.3
Bokeh version : 1.3.4
BokehJS static path : c:\python37\lib\site-packages\bokeh\server\static
node.js version : (not installed)
npm version : (not installed)

In order to experiment with various types of plots, the Bokeh website https://bokeh.pydata.org makes available sample datasets. They can be downloaded to a local machine by sample data subcommand.

C:\python37>bokeh info

Following datasets are downloaded in C:\Users\User\.bokeh\data folder โˆ’

AAPL.csv                                     airports.csv
airports.json                                CGM.csv
FB.csv                                       gapminder_fertility.csv
gapminder_life_expectancy.csv                gapminder_population.csv
gapminder_regions.csv                        GOOG.csv
haarcascade_frontalface_default.xml          IBM.csv
movies.db                                    MSFT.csv
routes.csv                                   unemployment09.csv
us_cities.json                               US_Counties.csv
world_cities.csv
WPP2012_SA_DB03_POPULATION_QUINQUENNIAL.csv

The secret subcommand generates a secret key to be used along with the serve subcommand with the SECRET_KEY environment variable.

Next Topic – Click Here

This Post Has One Comment

Leave a Reply