Search code examples
pythonbokeh

Ttle and color attributes not working on this bokeh graph


The code:

import pandas
from bokeh.plotting import figure, output_file, show
 
p=figure(plot_width=500,plot_height=400, tools='pan',logo=None)
 
p.title.text="Cool Data"
p.title.text_color="Gray"
p.title.text_font="times"
p.title.text_font_style="bold"
p.xaxis.minor_tick_line_color=None
p.yaxis.minor_tick_line_color=None
p.xaxis.axis_label="Date"
p.yaxis.axis_label="Intensity"    
 
p.line([1,2,3],[4,5,6])
output_file("graph.html")
show(p)

The error:

Traceback (most recent call last):
  File "basic_graph.py", line 4, in <module>
    p=figure(plot_width=500,plot_height=400, tools='pan',logo=None)
  File "C:\Users\Dhruva Jindal\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bokeh\plotting\figure.py", line 1364, in figure
    return Figure(**kwargs)
  File "C:\Users\Dhruva Jindal\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bokeh\plotting\figure.py", line 155, in __init__
    super().__init__(*arg, **kw)
  File "C:\Users\Dhruva Jindal\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bokeh\model.py", line 234, in __init__
    super().__init__(**kwargs)
  File "C:\Users\Dhruva Jindal\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bokeh\core\has_props.py", line 247, in __init__
    setattr(self, name, value)
  File "C:\Users\Dhruva Jindal\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bokeh\core\has_props.py", line 281, in __setattr__
    raise AttributeError("unexpected attribute '%s' to %s, %s attributes are %s" %
AttributeError: unexpected attribute 'logo' to Figure, possible attributes are above, align, aspect_ratio, aspect_scale, background, background_fill_alpha, background_fill_color, below, border_fill_alpha, border_fill_color, center, css_classes, disabled, extra_x_ranges, extra_y_ranges, frame_height, frame_width, height, 
height_policy, hidpi, inner_height, inner_width, js_event_callbacks, js_property_callbacks, 
left, lod_factor, lod_interval, lod_threshold, lod_timeout, margin, match_aspect, max_height, max_width, min_border, min_border_bottom, min_border_left, min_border_right, min_border_top, min_height, min_width, name, outer_height, 
outer_width, outline_line_alpha, outline_line_cap, outline_line_color, outline_line_dash, outline_line_dash_offset, outline_line_join, outline_line_width, output_backend, plot_height, 
plot_width, renderers, reset_policy, right, sizing_mode, subscribed_events, tags, title, title_location, toolbar, toolbar_location, toolbar_sticky, visible, width, width_policy, x_range, x_scale, y_range or y_scale

The above was the code which I was running Please let me know where the issue is in this piece of code. I have also pasted the error code which I hot when I was running this code so that you know what exactly is the issue.


Solution

  • If you want the toolbar to be hidden completely, instead of logo=None, pass in toolbar_location=None with your Figure args.

    If you want the toolbar, just without the logo, after your Figure is declared add this line: p.toolbar.logo = None