- 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.
推薦閱讀
- iOS面試一戰(zhàn)到底
- Python數(shù)據(jù)分析入門與實戰(zhàn)
- Arduino by Example
- Mastering OpenCV Android Application Programming
- PostgreSQL Cookbook
- Mastering Kali Linux for Web Penetration Testing
- Building a Quadcopter with Arduino
- Java EE 7 Performance Tuning and Optimization
- INSTANT Yii 1.1 Application Development Starter
- Illustrator CC平面設(shè)計實戰(zhàn)從入門到精通(視頻自學全彩版)
- TypeScript 2.x By Example
- Mastering ASP.NET Core 2.0
- SFML Game Development
- 數(shù)據(jù)結(jié)構(gòu)與算法詳解
- ASP.NET jQuery Cookbook(Second Edition)