-2
$\begingroup$

Given a csv of the form:

x, y, annotation

How can we efficiently (least code) generate an interactive (zoom/pan) scatterplot where the annotation appears when mousing-over or clicking on an individual point?

This is very helpful when evaluating clusterings.

$\endgroup$
  • 1
    $\begingroup$ All of them (at least, the ones you tagged: R, python, JS). So what? $\endgroup$ – Spacedman Oct 13 '17 at 19:13
  • $\begingroup$ Built-in in ELKI, no code required. Open the scatterplot, in the menu choose the label tooltip to enable the mouseovers. $\endgroup$ – Has QUIT--Anony-Mousse Oct 13 '17 at 19:52
2
$\begingroup$

Here's a way to do it in Python, in a Jupyter notebook, with bokeh:

from bokeh.plotting import figure, output_notebook, show
from bokeh.models.sources import ColumnDataSource
from bokeh.models import HoverTool, BoxZoomTool, PanTool, WheelZoomTool

import pandas as pd

df = pd.read_csv("your.csv")
source = ColumnDataSource(df_plot)
hover = HoverTool(tooltips=[("info", "@annotation")])
p = figure(plot_width=400, plot_height=400, tools=[hover, BoxZoomTool(), PanTool(), WheelZoomTool()])
p.circle('x', 'y', size=7, source=source)

output_notebook()
show(p)

This gives you an interactive, exploratory chart right in the notebook.

| improve this answer | |
$\endgroup$
2
$\begingroup$

Just to add to @Pete response (I don't have enough reputation to comment), if you're not using Jupyter just remove the output_notebook() line and add output_file("csv_plot.html") so it looks like this:

from bokeh.plotting import figure, output_notebook, show
from bokeh.models.sources import ColumnDataSource
from bokeh.models import HoverTool, BoxZoomTool, PanTool, WheelZoomTool

import pandas as pddf = pd.read_csv("your.csv")

source = ColumnDataSource(df_plot)
output_file("csv_plot.html")
hover = HoverTool(tooltips=[("info", "@annotation")])
p = figure(plot_width=400, plot_height=400, tools=[hover, BoxZoomTool(),     PanTool(), WheelZoomTool()])
p.circle('x', 'y', size=7, source=source)

show(p)

This will save the plot in your current working directory and then open the plot in your browser when it's done generating it. Check out the bokeh docs for more info

| improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.