Can anyone see what's wrong with my code

This is my code , help for me!
Code:

from bokeh.plotting import figure, show, output_file

output_file("f:/pythonword/2323/prd.html")

x = [1, 2, 3, 4]
y = [2, 4, 6, 8]

p = figure(title= "cmid", x_axis_label="x", y_axis_label="y", width=400, height=400)
p.line(x,y, legend="Temp", glyph_renderer=2)
show(p)

output

Traceback (most recent call last):
  File "f:\pythonword\2323\printt.py", line 9, in <module>
    p.line(x,y, legend="Temp", glyph_renderer=2)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\plotting\_decorators.py", line 87, in wrapped
    return create_renderer(glyphclass, self.plot, **kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\plotting\_renderer.py", line 113, in create_renderer
    glyph = make_glyph(glyphclass, kwargs, glyph_visuals)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\plotting\_renderer.py", line 142, in make_glyph
    return glyphclass(**kws)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\glyphs.py", line 952, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\glyph.py", line 91, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\glyph.py", line 80, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\glyph.py", line 101, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\glyph.py", line 58, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\model\model.py", line 110, in __init__
    super().__init__(**kwargs)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\core\has_props.py", line 295, in __init__
    setattr(self, name, value)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\core\has_props.py", line 333, in __setattr__
    self._raise_attribute_error_with_matches(name, properties)
  File "C:\Users\wong\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\core\has_props.py", line 368, in _raise_attribute_error_with_matches        
    raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")
AttributeError: unexpected attribute 'glyph_renderer' to Line, possible attributes are decorations, js_event_callbacks, js_property_callbacks, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, name, subscribed_events, syncable, tags, x or y

The error message tells you what the problem is. You are passing the keyword argument glyph_renderer to the line call, and there is no such argument. The error message lists all the valid attributes.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.