각 줄마다 두 점을 기준으로 bokeh
플롯에 10,000 줄을 추가하고 싶습니다. 1을 1 씩 추가하면 속도가 매우 느리고 최대 1 시간이 소요될 수 있습니다. 이 속도를 높이는 방법이 있습니까?Bokeh에 일괄 적분 추가
import pandas as pd
import numpy as np
from bokeh.plotting import figure, show, output_file
output_file('temp.html')
p = figure(plot_width=500, plot_height=400)
df = pd.DataFrame(np.random.randint(0,100,size=(10000, 4)), columns=['x1', 'x2', 'y1', 'y2'])
print df
for index, row in df.iterrows():
p.line([row['x1'], row['x2']], [row['y1'], row['y2']], line_width=2)
show(p)
는 편집 : 여러 줄
와
import pandas as pd
from bokeh.models.glyphs import MultiLine
from bokeh.models import ColumnDataSource
import numpy as np
from bokeh.plotting import figure, show, output_file
output_file('temp.html')
p = figure(plot_width=500, plot_height=400,
)
df = pd.DataFrame(np.random.randint(0, 100, size=(10000, 4)), columns=['x1', 'x2', 'y1', 'y2'])
source = ColumnDataSource(dict(
xs=df[['x1', 'x2']].as_matrix(),
ys=df[['y1', 'y2']].as_matrix(),
)
)
glyph = MultiLine(xs="xs", ys="ys", line_color="#8073ac", line_width=2)
p.add_glyph(source, glyph)
show(p)
감사합니다. 나는 Datashader를 살펴볼 것이지만, 지금은 Multiline을 시도하고 싶다. 이 문서 사용 https://bokeh.pydata.org/en/latest/docs/reference/models/glyphs/multi_line.html. 업데이트 된 코드로 원래 질문을 편집했지만 지금은 그냥 빈 차트를 얻었습니다 – user2242044
사실, 데이터는 항상 시작/끝 및 다른 점이없는 항상 단일 세그먼트 선입니까? 만약 그렇다면 당신은'segment'를 사용해야합니다. 이것은 그 종류의 비주얼을 벡터화하기 위해서 존재하며,'multi_line'보다 데이터를 준비하기 쉽습니다. https://bokeh.pydata.org/en/latest/docs/reference/plotting. html # bokeh.plotting.figure.Figure.segment – bigreddot
예, 데이터 프레임의 각 행은 x0, x1, y0, y1을 나타냅니다. 설명서를 빠르게 살펴 봤는데 올바른 응용 프로그램처럼 보입니다. – user2242044