首页 > 解决方案 > Ttle 和颜色属性不适用于此散景图

问题描述

编码:

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)

错误:

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

以上是我正在运行的代码请让我知道这段代码的问题所在。我还粘贴了我在运行此代码时很热的错误代码,以便您知道究竟是什么问题。

标签: pythonbokeh

解决方案


如果您希望工具栏完全隐藏,而不是,请使用您的 Figure argslogo=None传入。toolbar_location=None

如果你想要工具栏,只是没有标志,在你的 Figure 被声明后添加这一行: p.toolbar.logo = None


推荐阅读