1

I'm trying to plot a quad plot using Bokeh. The structure of the code that's giving me errors closely resembles what I have bellow.

my_dict = {...} # has the following keys [left, right, bottom, top, color]

p = figure(width = 800, height = 800)

source= ColumnDataSource(data = my_dict)

p.quad(source,
       top="top",
       bottom = "bottom",
       left = "left",
       right = "right",
       color = "color")  

This yields the following error:

TypeError: quad() got multiple values for argument 'left'

The length of all lists in my dict are equal. I checked using:

for key in my_dict.keys():
  print(len(my_dict[key ]))

I'm not sure how to proceed. I've also type checked each entry for 'left' to see if it was complaining about inconsistent typing. Any ideas?

1 Answer 1

1

The first argument to quad is not the data source:

http://docs.bokeh.org/en/latest/docs/reference/plotting.html#bokeh.plotting.figure.Figure.quad

It is left, which means in the code above, you are passing a value for left both as a positional argument (but giving it source as a value) as well as passing left as a keyword argument. This is exactly the situation that will cause Python to complain:

>>> def foo(arg): pass
...
>>> foo(10, arg=20)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() got multiple values for keyword argument 'arg'

You need to pass source as a keyword argument (as all the examples demonstrate):

p.quad(top="top",
       bottom="bottom",
       left="left",
       right="right",
       color="color",
       source=source)  

Not the answer you're looking for? Browse other questions tagged or ask your own question.