3

サーバーにさまざまなサイズの長方形をプロットしようとしています。hold() を使用して一度にすべてをプロットする方法を見つけました。これが得られるものです

http://postimg.org/image/mh8z0z6nz/

これが私がプロットに使用したコードです

import bokeh.plotting as bk
from bokeh.plotting import *

html_title="height=%r and width='%r'"%(height,width)
bk.output_file("maxrects.html",title="MAXRECTS")                #saving output to a file
bk.figure(plot_width=600,plot_height=600,title=html_title)      #plot specifics


bk.hold()                                                       
x_cor=[]
y_cor=[]
b_width=[]
b_height=[]


bk.rect([width/2],                                              #plotting the bin
    [int(height)/2],
    [width],
    [int(height)],fill_color="crimson")


bk.hold()                                                       #disables overwriting of         any previous glyph


for pr in maxbin.usedRectangles:                                
    b_x=pr.x+pr.width/2                                         #gets centre co-ordinates       of each used rectangle
    b_y=pr.y+pr.height/2
    x_cor.append(int(b_x))
    y_cor.append(int(b_y))
    b_width.append(int(pr.width))
    b_height.append(int(pr.height))

bk.rect(x_cor,                                                  #plotting function
    y_cor,
    b_width,
    b_height,fill_color="black")
 bk.save()                                                      #saves the output
 bk.show()              

高さと幅がユーザーによって入力され、ビン (クリムゾン) が初期化されます。UsedRectangles にはすべての黒い四角形が含まれます (x、y、幅、高さは各四角形オブジェクトの属性です)

各オブジェクトを次々にセッションに送信したい.基本的に、プロットはライブ(動的)である必要があります.長方形は次々にプロットする必要があります. どんな助けでも大歓迎です!

matplotlib を使用した回避策も受け入れられます

4

0 に答える 0