散景,酒吧和折线图的组合

时间:2015-06-04 12:20:39

标签: bokeh

我试图在散景图中的条形图上绘制一条线。我试过了:

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php-cgi
</FilesMatch>
<IfModule actions_module>
    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
</IfModule>

到目前为止,我没有运气。

1 个答案:

答案 0 :(得分:6)

使用Basic Glyphs可以在Bokeh的一个图中组合两个或多个图。

对于你的问题,我们可以使用line和rect。

from bokeh.plotting import figure, output_file, show
from bokeh.models.ranges import Range1d
import numpy


output_file("line_bar.html")

p = figure(plot_width=400, plot_height=400)

# add a line renderer
p.line([1, 2, 3, 4, 5], [6, 7, 6, 4, 5], line_width=2)

# setting bar values
h = numpy.array([2, 8, 5, 10, 7])

# Correcting the bottom position of the bars to be on the 0 line.
adj_h = h/2

# add bar renderer
p.rect(x=[1, 2, 3, 4, 5], y=adj_h, width=0.4, height=h, color="#CAB2D6")

# Setting the y  axis range   
p.y_range = Range1d(0, 12)

p.title = "Line and Bar"

show(p)

我们得到的情节:

enter image description here

相关问题