AttributeError: неожиданный атрибут «отзывчивый» на рисунок - PullRequest
0 голосов
/ 01 апреля 2020
import pandas_datareader.data as web
import datetime
from bokeh.plotting import figure,show, output_file

start = datetime.datetime(2016,11,1)
end = datetime.datetime(2017,3,10)
df = web.DataReader("TSLA", "yahoo", start, end)
p = figure(x_axis_type='datetime',width=1000, height=300, responsive=True)

def inc_dec(c,o):
    if c > o:
        value = "Increase"
    elif c < o:
        value = "Decrease"
    else:
        value = "Equal"
    return  value

df["status"] = [inc_dec(c,o) for c,o in zip(df.Close,df.Open)]
df["Middle"] = (df.Open + df.Close)/2
df["Height"] = abs(df.Close -df.Open)

hours_12 = 12 * 60 * 60 * 1000

p.rect(df.index[df.Status == "Increase"],
       df.Middle[df.Status == "Increase"],
       hours_12,
       df.Height[df.Status == "Increase"],
       fill_color = "#CCFFFF",
       line_color = "black"
       )

p.rect(df.index[df.Status == "Decrease"],
       df.Middle[df.Status == "Decrease"],
       hours_12,
       df.Height[df.Status == "Decrease"],
       fill_color = "#FF3333",
       line_color = "black"
       )

output_file("Graph.html")
show(p) 

Отладочный вывод

E:\PycharmProjects\RL\venv\Scripts\python.exe "E:\PyCharm Community Edition 2019.1.3\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 51236 --file E:/PycharmProjects/RL/Myflie/bitkubAPI/RealStockGraph.py
pydev debugger: process 4776 is connecting

Connected to pydev debugger (build 193.6015.41)
E:\PycharmProjects\RL\venv\lib\site-packages\pandas_datareader\compat\__init__.py:7: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
  from pandas.util.testing import assert_frame_equal
Traceback (most recent call last):
  File "E:\PyCharm Community Edition 2019.1.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1434, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "E:\PyCharm Community Edition 2019.1.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:/PycharmProjects/RL/Myflie/bitkubAPI/RealStockGraph.py", line 8, in <module>
    p = figure(x_axis_type='datetime',width=1000, height=300, responsive=True)
  File "E:\PycharmProjects\RL\venv\lib\site-packages\bokeh\plotting\figure.py", line 1364, in figure
    return Figure(**kwargs)
  File "E:\PycharmProjects\RL\venv\lib\site-packages\bokeh\plotting\figure.py", line 155, in __init__
    super().__init__(*arg, **kw)
  File "E:\PycharmProjects\RL\venv\lib\site-packages\bokeh\model.py", line 234, in __init__
    super().__init__(**kwargs)
  File "E:\PycharmProjects\RL\venv\lib\site-packages\bokeh\core\has_props.py", line 247, in __init__
    setattr(self, name, value)
  File "E:\PycharmProjects\RL\venv\lib\site-packages\bokeh\core\has_props.py", line 282, in __setattr__
    (name, self.__class__.__name__, text, nice_join(matches)))
AttributeError: unexpected attribute 'responsive' 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

следующая ошибка при редактировании, реагирующая на sizing_mode, если sizing_mode = True, измените на sizing_mode = "scale_width", sizing_mode = "stretch_both", sizing_mode = "fixed", sizing_mode = "stretch_width", sizing_mode = "stretch_both"

Похоже, ваш пост в основном кодовый; пожалуйста, добавьте больше деталей.

1 Ответ

0 голосов
/ 01 апреля 2020

Ответ находится в исключении (не предупреждение):

AttributeError: неожиданный атрибут «отзывчивый» на рисунок,

Параметр responsive был удален несколько лет a go.

В любой достаточно современной версии Bokeh вы хотели бы указать sizing_mode вместо:

https://docs.bokeh.org/en/latest/docs/user_guide/layout.html?highlight=sizing_mode#sizing -режим

...