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

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. 

主站蜘蛛池模板: 视频| 平利县| 丹阳市| 延津县| 旌德县| 金湖县| 木兰县| 湘西| 南京市| 汉中市| 旬阳县| 汨罗市| 临桂县| 颍上县| 开平市| 类乌齐县| 建瓯市| 灌阳县| 香格里拉县| 长葛市| 西和县| 辽宁省| 揭西县| 额尔古纳市| 宁南县| 延安市| 库尔勒市| 临漳县| 顺义区| 白银市| 沙湾县| 师宗县| 云龙县| 蓬溪县| 绿春县| 华安县| 宝清县| 安泽县| 古田县| 霍邱县| 八宿县|