- Hands-On Data Visualization with Bokeh
- Kevin Jolly
- 177字
- 2021-06-25 20:50:22
Creating line plots
We can plot a simple line plot in Bokeh using the following code:
#Importing the required packages
from bokeh.io import output_file, show
from bokeh.plotting import figure
#Creating our data arrays used for plotting the line plot
x = [5,6,7,8,9,10]
y = [1,2,3,4,5,6]
#Calling the figure() function to create the figure of the plot
plot = figure()
#Creating a line plot using the line() function
plot.line(x,y)
#Creating markers on our line plot at the location of the intersection between x and y
plot.cross(x,y, size = 15)
#Output the plot
output_file('line_plot.html')
show(plot)
This results in a plot illustrated as follows:
In the preceding code, we first called the figure() function as a way to instruct Bokeh to construct a diagram. Once we've done this, we can then add layers of glyphs or geometric shapes to our diagram.
We first added the line() glyph to the figure in order to construct the line plot and then added the cross() glyph on top of the line to mark intersections between the x and y points.
推薦閱讀
- C++程序設計教程
- LaTeX Cookbook
- 架構不再難(全5冊)
- Vue.js入門與商城開發實戰
- MATLAB定量決策五大類問題
- Hands-On Swift 5 Microservices Development
- 劍指Java:核心原理與應用實踐
- Apache Kafka Quick Start Guide
- Web性能實戰
- Unity Character Animation with Mecanim
- Python商務數據分析(微課版)
- MyBatis 3源碼深度解析
- 寫給大家看的Midjourney設計書
- MongoDB Cookbook(Second Edition)
- 高效使用Greenplum:入門、進階與數據中臺