끄적끄적 코딩
article thumbnail
[bokeh] 내보내기(Exporting)
bokeh 2020. 10. 5. 15:00

from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG from bokeh.palettes import Spectral4 p = figure(plot_width=800, plot_height=250, x_axis_type="datetime") for data, name, color in zip([AAPL, IBM, MSFT, GOOG], ["AAPL", "IBM", "MSFT", "GOOG"], Spectral4): datetime = np.asarray(data['date'], dtype=np.datetime64) value = np.asarray(data['close']) p.line(datetime, value, line_width=1, color=c..

article thumbnail
[bokeh] 막대, 범주형 데이터 플롯 (Bar, Categorical Data Plots)
bokeh 2020. 10. 5. 14:57

from bokeh.models import ColumnDataSource from bokeh.palettes import Spectral6 cities = ['서울특별시', '부산광역시', '인천광역시', '대구광역시', '대전광역시', '광주광역시'] pops = [9720846, 3404423, 2947217, 2427954, 1471040, 1455048] source = ColumnDataSource(data=dict(cities=cities, pops=pops, color=Spectral6)) p = figure(x_range=cities, plot_height=300, y_range=(0, 10000000), title="Populations") p.vbar(x='cities', top='p..

article thumbnail
[bokeh] 위젯 (Widgets)
bokeh 2020. 10. 5. 14:44

from bokeh.layouts import column from bokeh.models import CustomJS, ColumnDataSource, Slider x = [x*0.005 for x in range(0, 201)] source = ColumnDataSource(data=dict(x=x, y=x)) plot = figure(plot_width=400, plot_height=400) plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6,) slider = Slider(start=0.1, end=8, value=1, step=.1, title="power") update_curve = CustomJS(args=dict(source=..

article thumbnail
[bokeh] 연결된 상호작용 (Linked Interactions)
bokeh 2020. 10. 5. 14:34

plot_options = dict(width=250, plot_height=250, tools='pan, wheel_zoom') s1 = figure(**plot_options)#플롯 옵션을 가져옴 s1.square(x, y1, size=10, color="red", alpha=0.5) s2 = figure(x_range=s1.x_range, **plot_options) # s1의 x_range를 넣어서 연결되게 함 s2.square(x, y2, size=10, color="green", alpha=0.5) s3 = figure(y_range=s1.y_range, **plot_options) # s1의 y_range를 넣어서 연결되게 함 s3.square(x, y3, size=10, color="blu..

article thumbnail
[bokeh] 레이아웃 (Layout)
bokeh 2020. 10. 5. 13:59

row from bokeh.layouts import row x = list(range(10)) y1 = np.random.randint(1, 10, 10) y2 = np.random.randint(1, 10, 10) y3 = np.random.randint(1, 10, 10) s1 = figure(width=250, plot_height=250) s1.square(x, y1, size=10, color="red", alpha=0.5) s2 = figure(width=250, plot_height=250) s2.square(x, y2, size=10, color="green", alpha=0.5) s3 = figure(width=250, plot_height=250) s3.square(x, y3, siz..

article thumbnail
[bokeh] 주석 (Annotations)
bokeh 2020. 10. 5. 13:40

스판 (Span) from bokeh.models.annotations import Span x = np.linspace(0, 50, 100) y1 = np.sin(x) y2 = np.cos(x) p = figure(y_range=(-2, 2)) p.line(x, y1, color="red") p.line(x, y2, color="blue") upper = Span(location=1, dimension='width', line_color="red", line_width=4) # 위치 1, 가로, 빨강, 길이- 4 p.add_layout(upper) lower = Span(location=-1, dimension='width', line_color="blue", line_width=4) # 위치 -1, ..

article thumbnail
[bokeh] 데이터 제공
bokeh 2020. 10. 5. 09:50

데이터 직접 제공 x = [1, 2, 3, 4, 5] y = [4, 5, 2, 4, 6] p = figure(plot_width=400, plot_height=400) p.circle(x, y) show(p) ColumnDataSource - 앱 이름과 데이터 목록 사이의 매핑 - Bokeh 플롯의 핵심으로 플롯에서 글리프의 시각화된 데이터 제공 - DataTable과 같은 여러 플롯과 위젯간의 데이터를 쉽게 공유 from bokeh.models import ColumnDataSource data = {'x': [1, 2, 3, 4, 5], 'y': [4, 5, 2, 4, 6]} source = ColumnDataSource(data=data) p = figure(plot_width=400, plot_h..

article thumbnail
[bokeh] 스타일 (Style)
bokeh 2020. 10. 5. 09:17

색상 - HTML 색상 표현 - RGB 16진수로 표현 - 0~255 정수값 (r, g, b) 튜플 형태로 표현 - 0~1 사이의 부동소수점 a가 추가된 (r, g, b, a) 튜플 형태로 표현 플롯 (Plots) x = np.random.randint(1, 10, 10) y = np.random.randint(1, 10, 10) p = figure(plot_width=400, plot_height=400) p.outline_line_width = 10 p.outline_line_alpha = 0.5 p.outline_line_color = "orange" p.circle(x, y, color="red", size=10) show(p) 글리프 (Glyphs) p = figure(plot_width=400..

검색 태그