2

I'm building up a list of plots programatically in a Python list and I'd like to throw it at the vplot function instead of the grid I'm currently using. The documentation has the explicit enumeration of the children but I'm wondering if I can take a list of figure objects and receive them into vplot somehow much like how is done for the grid object.

channelPlots = []

for channel in myChannels :
    channelPlot = figure( width=1000, height=1000 , title=channel+ " Time Series" , x_axis_label = channel , y_axis_label = "TIME" )
    y           = sample.data['TIME' ]
    x           = sample.data[channel]
    channelPlot.scatter(x,y)
    channelPlots.append(channelPlot)

# With a grid it works  
#grid = GridPlot(children=[channelPlots], title="Time Series Channel Plots")

# with a vplot it breaks
grid = vplot( channelPlots )
save(grid)


Exception error is: expected an element of List(Instance(Widget)), got [[<bokeh.plotting.Figure object at 0x0000000009AA2128>, <bokeh.plotting.Figure object at 0x0000000006778CF8>, <bokeh.plotting.Figure object at 0
x0000000011894C50>, <bokeh.plotting.Figure object at 0x00000000118DE390>, <bokeh.plotting.Figure object at 0x00000000118DEF98>, <bokeh.plotting.Figure object at 0x00000000118F2668>, <bokeh.plotting.Figure object at
0x00000000118EE7B8>, <bokeh.plotting.Figure object at 0x00000000118EE630>]]

and attempting both of these below threw the same exception...

grid = vplot(children=channelPlots)
grid = vplot(children=[channelPlots])
Exception error is: Viewable object got multiple values for keyword argument 'children'
jxramos
  • 7,356
  • 6
  • 57
  • 105

1 Answers1

3

You either need to pass the list explicitly as the children parameter:

grid = vplot(children=channelPlots)

Or alternatively, vplot accepts the children as *args:

grid = vplot(*channelPlots)
bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • The first method, which I also tried yesterday, threw an exception for me. I updated the Question to list that attempt too. The second one worked for me though. Solid! – jxramos Aug 18 '15 at 18:42
  • did you try both of them at the same time as you seem to have done above? the `vplot(children=[channelPlots])` one will definitely throw the exception. `children` accepts a list, and `channelPlots` is already a list, so when you do `vplot(children=[channelPlots])` you are trying to set a list of lists, which is an error. – bigreddot Aug 18 '15 at 18:47
  • Oh, actually I just noticed the exception is different than I expected, I think you found a small bug. Can you file a GH issue about it? – bigreddot Aug 18 '15 at 18:47
  • I tried them one at a time, but both threw the same exception. I'm using `>>> bokeh.__version__ '0.9.2'`. I just double checked again,... `print(type(channelPlots)) grid = vplot(children=channelPlots) Exception error is: Viewable object got multiple values for keyword argument 'children'` – jxramos Aug 18 '15 at 18:57
  • Just submitted, _Bug in vplot/hplot children argument #2740_ – jxramos Aug 18 '15 at 19:11
  • Very cool, didn't realize this asterisk character was a formal operator in Python, [argument-unpacking operator](http://stackoverflow.com/questions/400739/what-does-asterisk-mean-in-python/406488#406488) – jxramos Aug 25 '15 at 00:54