# importing the modules
from bokeh.sampledata.iris import flowers
from bokeh.plotting import figure, show, output_file
# file to save the model
output_file("gfg.html")
# instantiating the figure object
graph = figure(title="Iris Visualization")
# labeling the x-axis and the y-axis
graph.xaxis.axis_label = "Length (in cm)"
graph.yaxis.axis_label = "Width (in cm)"
# plotting for setosa petals
x = flowers[flowers["species"] == "setosa"]["petal_length"]
y = flowers[flowers["species"] == "setosa"]["petal_width"]
marker = "circle_cross"
line_color = "blue"
fill_color = "lightblue"
fill_alpha = 0.4
size = 10
legend_label = "setosa petals"
graph.scatter(x, y,
marker=marker,
line_color=line_color,
fill_color=fill_color,
fill_alpha=fill_alpha,
size=size,
legend_label=legend_label)
# plotting for setosa sepals
x = flowers[flowers["species"] == "setosa"]["sepal_length"]
y = flowers[flowers["species"] == "setosa"]["sepal_width"]
marker = "square_cross"
line_color = "blue"
fill_color = "lightblue"
fill_alpha = 0.4
size = 10
legend_label = "setosa sepals"
graph.scatter(x, y,
marker=marker,
line_color=line_color,
fill_color=fill_color,
fill_alpha=fill_alpha,
size=size,
legend_label=legend_label)
# plotting for versicolor petals
x = flowers[flowers["species"] == "versicolor"]["petal_length"]
y = flowers[flowers["species"] == "versicolor"]["petal_width"]
marker = "circle_cross"
line_color = "yellow"
fill_color = "lightyellow"
fill_alpha = 0.4
size = 10
legend_label = "versicolor petals"
graph.scatter(x, y,
marker=marker,
line_color=line_color,
fill_color=fill_color,
fill_alpha=fill_alpha,
size=size,
legend_label=legend_label)
# plotting for versicolor sepals
x = flowers[flowers["species"] == "versicolor"]["sepal_length"]
y = flowers[flowers["species"] == "versicolor"]["sepal_width"]
marker = "square_cross"
line_color = "yellow"
fill_color = "lightyellow"
fill_alpha = 0.4
size = 10
legend_label = "versicolor sepals"
graph.scatter(x, y,
marker=marker,
line_color=line_color,
fill_color=fill_color,
fill_alpha=fill_alpha,
size=size,
legend_label=legend_label)
# plotting for virginica petals
x = flowers[flowers["species"] == "virginica"]["petal_length"]
y = flowers[flowers["species"] == "virginica"]["petal_width"]
marker = "circle_cross"
line_color = "red"
fill_color = "lightcoral"
fill_alpha = 0.4
size = 10
legend_label = "virginica petals"
graph.scatter(x, y,
marker=marker,
line_color=line_color,
fill_color=fill_color,
fill_alpha=fill_alpha,
size=size,
legend_label=legend_label)
# plotting for virginica sepals
x = flowers[flowers["species"] == "virginica"]["sepal_length"]
y = flowers[flowers["species"] == "virginica"]["sepal_width"]
marker = "square_cross"
line_color = "red"
fill_color = "lightcoral"
fill_alpha = 0.4
size = 10
legend_label = "virginica sepals"
graph.scatter(x, y,
marker=marker,
line_color=line_color,
fill_color=fill_color,
fill_alpha=fill_alpha,
size=size,
legend_label=legend_label)
# relocating the legend table to
# avoid abstruction of the graph
graph.legend.location = "top_left"
# displaying the model
show(graph)