Build to server (stream rectangles) bin packing
I am trying to plot different sized rectangles on the server. I figured out how to build them all at once using hold () and this is what I get
http://postimg.org/image/mh8z0z6nz/
here's the code i used build
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()
the height and width are entered by the user and the bin (crimson) is initialized. UsedRectangles contain all black rectangles (x, y, width, height are attributes of each rectangle object)
I want to send each object to the session one by one. Basically, the plotting should be live (dynamic). The rectangles must be drawn one by one. Any help would be greatly appreciated!
also an acceptable workaround with matplotlib
+3
source to share
No one has answered this question yet
Check out similar questions: