官术网_书友最值得收藏!

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. 

主站蜘蛛池模板: 贺兰县| 宣恩县| 泰和县| 海原县| 读书| 汾阳市| 乌拉特中旗| 织金县| 大新县| 云和县| 彭泽县| 越西县| 桓台县| 碌曲县| 城口县| 永和县| 大埔县| 襄城县| 颍上县| 晴隆县| 克拉玛依市| 绥阳县| 宁德市| 阳西县| 改则县| 伊金霍洛旗| 靖边县| 丹阳市| 大渡口区| 蓬安县| 石柱| 临颍县| 山阳县| 兴山县| 浦县| 云南省| 宜宾县| 横山县| 凤山县| 兴文县| 浦城县|