1
|
|
|
import numpy as np |
|
|
|
|
2
|
|
|
import pandas as pd |
|
|
|
|
3
|
|
|
|
4
|
|
|
from bokeh.plotting import figure, curdoc, vplot, output_file, show |
|
|
|
|
5
|
|
|
from bokeh.embed import autoload_server, components |
|
|
|
|
6
|
|
|
from bokeh.client import push_session |
|
|
|
|
7
|
|
|
from bokeh.models import Button, ColumnDataSource |
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
def topic_cluster(data): |
|
|
|
|
11
|
|
|
output_file("topic_cluster.html") |
12
|
|
|
|
13
|
|
|
plot = figure() |
14
|
|
|
xcoords = data["x"] |
15
|
|
|
ycoords = data["y"] |
16
|
|
|
frequency = data["Freq"] |
17
|
|
|
for x, y, size in zip(xcoords, ycoords, frequency): |
|
|
|
|
18
|
|
|
plot.circle(x, y, size=(size*7), alpha=0.5) |
19
|
|
|
|
20
|
|
|
# curdoc().add_root(plot) |
21
|
|
|
# session = push_session(curdoc()) |
22
|
|
|
# script = autoload_server(model=None, session_id=session.id) |
23
|
|
|
# return script |
24
|
|
|
show(plot) |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
def word_frequency(data): |
|
|
|
|
28
|
|
|
factors = ["a", "b", "c", "d", "e", "f", "g", "h"] |
29
|
|
|
x = [50, 40, 65, 10, 25, 37, 80, 60] |
|
|
|
|
30
|
|
|
output_file("word_frequency.html") |
31
|
|
|
plot = figure(y_range=factors, x_range=[0,100]) |
|
|
|
|
32
|
|
|
plot.segment(0, factors, x, factors, line_width=10, line_color="green") |
33
|
|
|
show(plot) |
34
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.