Created
January 22, 2022 13:50
-
-
Save misgeatgit/962d4c074c1beafa84ff475578ab529f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.plotting import figure | |
from bokeh.models import ColumnDataSource, HoverTool | |
from bokeh.plotting import figure, output_file, show | |
def location_plot(title, colors): | |
whisky_csv = "whiskies.csv" | |
whisky = pd.read_csv(whisky_csv) | |
output_file(title+".html") | |
location_source = ColumnDataSource( | |
data = { | |
"x": whisky[" Latitude"], | |
"y": whisky[" Longitude"], | |
"colors": colors, | |
"regions": whisky.Region, | |
"distilleries": whisky.Distillery | |
} | |
) | |
fig = figure(title = title, | |
x_axis_location = "above", tools="hover, save") | |
fig.plot_width = 400 | |
fig.plot_height = 500 | |
fig.circle("x", "y", size=9, source=location_source, color='colors', line_color = None) | |
fig.xaxis.major_label_orientation = np.pi / 3 | |
hover = fig.select(dict(type = HoverTool)) | |
hover.tooltips = { | |
"Distillery": "@distilleries", | |
"Location": "(@x, @y)" | |
} | |
show(fig) | |
cluster_colors = ["red", "orange", "green", "blue", "purple", "gray"] | |
location_plot("Whisky Locations and Regions", cluster_colors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment