我正在开发一个基于选项卡的本地Bokeh应用程序,并试图在这个应用程序的第一个选项卡中包含一个matplotlib对象。
对象是Venn图,它超出了Bokeh的范围。
到目前为止,我有这样的情况:
import bokeh
from bokeh.plotting import figure, output_file, show
from bokeh.layouts import row, column
import matplotlib.pyplot as plt
from matplotlib_venn import venn2
output_file('test.html')
scatter = figure(plot_width = 900, plot_height = 400)
scatter.circle([1,2,3,4,5,6], [3,5,7,9,11,16], size = 12, alpha = 0.6)
bar = figure(plot_width = 450, plot_height = 400)
bar.quad(top = [3,5,7,9,11,16], bottom = 0, left = [1,2,3,4,5,6], right = [1.9,2.9,3.9,4.9,5.9,6.9])
venn2([set(['A', 'B', 'C', 'D', 'E']), set(['A', 'C', 'E', 'G', 'I'])])
plots = column(scatter, bar)
show(plots)
理想情况下,我想以下面所示的方式定位Venn图。
我有些天真地认为,像column(scatter, row(bar, plt.show()))
这样的东西会起作用,但它不能。
我是Python的新手,我以前从未使用过MatPlotLib。
发布于 2019-09-27 11:24:18
详细说明: Bokeh和MPL之间没有任何内置的集成。如果要在某些Bokeh内容中嵌入MPL绘图,我可以想到两种方法:
Div
中的HTML标记来显示图像文件。ImageRGBA
字形在Bokeh图中“绘制”MPL图,如comment.Just中的一些合成的RGBA数据img =np.empty(20,20),dtype=np.uint32) view = img.view(dtype=np.uint8).reshape((N,N,4))中的i在范围(N):对于j在范围(N):viewi,j,0= int(i/N*255)视图,j,1= 158 viewi,j,j,2= int(j/N* 255 )视图,j,3=255 p=图()#必须给出图像的向量p.image_rgba(image=img,x=0,y=0,dw=10,dh=10)发布于 2020-07-18 02:10:49
另一种方法是使用土坡,它使用Bokeh/Holoview作为绘图后端。上面的链接展示了如何基于集合操作(圆圈)创建Venn图。
https://stackoverflow.com/questions/58131877
复制