# import modules
from bokeh.io import output_file, show
from bokeh.layouts import row
from bokeh.plotting import figure
import numpy as np
import random
# create a new plot
# instantiating the figure object
fig1 = figure(title="Plot 1")
# coordinates
x = [[[[0, 0, 1, 1]]],
[[[2, 2, 4, 4], [2.5, 2.5, 3.5, 3.5]]],
[[[2, 0, 4]]]]
y = [[[[2.5, 0.5, 0.5, 2.5]]],
[[[1, 0, 0, 1], [0.75, 0.25, 0.25, 0.75]]],
[[[2, 0, 0]]]]
# color values of the polygons
color = ["red", "purple", "yellow"]
# fill alpha values of the polygons
fill_alpha = 0.5
# plotting the graph
fig1.multi_polygons(x, y,
color=color,
fill_alpha=fill_alpha)
# create another plot
# coordinates
x = np.arange(5)
y = x**2
z = x*3
p = np.linspace(1, 20, 7)
q = np.linspace(1, 10, 7)
r = np.linspace(1, 30, 5)
a = np.arange(31)
# creating an empty figure with specific plot
# width and height
fig2 = figure(title="Plot 2")
# plotting the points in the form of
# circular glyphs
fig2.circle(x, y, color="red", size=20)
# plotting the points in the form of
# square glyphs
fig2.square(x, z, color="blue", size=15, alpha=0.5)
# plotting the points in the form of
# hex glyphs
fig2.hex(y, z, color="green", size=10, alpha=0.7)
# drawing a line between the plotted points
fig2.line(x, y, color="green", line_width=4)
# plotting the points in the form of
# inverted triangle glyph
fig2.inverted_triangle(p, q, color="yellow", size=20, alpha=0.4)
# plotting the points in the form of
# diamond glyphs
fig2.diamond(x, r, color="purple", size=16, alpha=0.8)
# plotting the points in the form of
# cross glyphs
fig2.cross(a, a, size=14)
# create a third plot
# generating the points to be plotted
x = []
y = []
for i in range(100):
x.append(i)
for i in range(100):
y.append(1 + random.random())
# parameters of line 1
line_color = "red"
line_dash = "solid"
legend_label = "Line 1"
fig3 = figure(title="Plot 3")
# plotting the line
fig3.line(x, y,
line_color=line_color,
line_dash=line_dash,
legend_label=legend_label)
# plotting line 2
# generating the points to be plotted
x = []
y = []
for i in range(100):
x.append(i)
for i in range(100):
y.append(random.random())
# parameters of line 2
line_color = "green"
line_dash = "dotdash"
line_dash_offset = 1
legend_label = "Line 2"
# plotting the line
fig3.line(x, y,
line_color=line_color,
line_dash=line_dash,
line_dash_offset=line_dash_offset,
legend_label=legend_label)
# depict visualization
show(row(fig1, fig2, fig3))