<reponame>mcvenkat/Python-Programs
#Plotting flower species

#Importing libraries
from bokeh.plotting import figure
from bokeh.io import output_file, show
from bokeh.sampledata.iris import flowers
from bokeh.models import Range1d, PanTool, ResetTool, HoverTool, ColumnDataSource, LabelSet

colormap={'setosa':'red','versicolor':'green','virginica':'blue'}
flowers['color'] = [colormap[x] for x in flowers['species']]
flowers['size'] = flowers['sepal_width'] * 4

setosa = ColumnDataSource(flowers[flowers["species"]=="setosa"])
versicolor = ColumnDataSource(flowers[flowers["species"]=="versicolor"])
virginica = ColumnDataSource(flowers[flowers["species"]=="virginica"])

#Define the output file path
output_file("iris.html")

#Create the figure object
f = figure()

#adding glyphs
f.circle(x="petal_length", y="petal_width", size='size', fill_alpha=0.2,
color="color", line_dash=[5,3], legend='Setosa', source=setosa)

f.circle(x="petal_length", y="petal_width", size='size', fill_alpha=0.2,
color="color", line_dash=[5,3], legend='Versicolor', source=versicolor)

f.circle(x="petal_length", y="petal_width", size='size', fill_alpha=0.2,
color="color", line_dash=[5,3], legend='Virginica', source=virginica)


#Style the legend
f.legend.location = "top_left"
f.legend.background_fill_alpha = 0
f.legend.border_line_color = None
f.legend.margin = 10
f.legend.padding = 18
f.legend.spacing = 1
f.legend.label_text_color = 'olive'
f.legend.label_text_font = 'antiqua'


#Save and show the figure
show(f)
