4

1

Say I have a list of 2-tuples that is visualized by `ListPlot`

. Each 2-tuple is also associated with another graph. Now what I want to realize is to display the corresponding graph by mouse-clicking "roughly" on the data point of the 2-tuple on the `ListPlot`

plot.

I have found a similar question, but here I have `ListPlot`

instead of `BarChart`

. So it is not straightforward to use `Button`

, as each data point has to be distinguished, but I do not know how to put `Button`

on every point or whether it is a good idea to do so since there are hundreds of points.

Edit 1:

Regarding performance.

Sample code:

```
graphGen[x_, y_] := ListPlot[Table[{x - i^2 y, x + i y}, {i, 0, 30}]]
BulkCode = Table[indexedGraphVariable[x, y] = graphGen[x, y], {x, -10., 10,
1}, {y, -10., 10, 1}];
popupGraph[pt_] := indexedGraphVariable @@ pt
toolRule = Tooltip[x__] :> PopupWindow[Tooltip[x], popupGraph@Last@{x}];
ListPlot[Tooltip@{Flatten[
Table[{x, y}, {x, -2, 10, 1}, {y, -10, 10, 1}], 1],
Flatten[Table[{x, y}, {x, -10, -1, 1}, {y, -10, 10, 1}], 1]},
ImageSize -> 1000] /. toolRule
```

- run the code
- open the system monitor, notice the memory used by MMA, which should be static, like 70MB
- click up ten popup windows and close them, check the memory again. It starts going up gradually until ~500MB
- if re-do the process, the used memory gets doubled

This code plots only 400 points. If there are ~10000 points, the popup-window clicking will cost several GB, and the interface slows down obviously.

EDIT 2:

The problem emerges actually when I try to click on the point but miss clicking on the background of the `ListPlot`

graph. The interface then starts to get slow. I suppose this is due to `ToolTip`

's underlying mechanism but do not know how?

2

You should look at

– m_goldberg – 2015-09-03T15:18:38.760`ClickPane`

. If you give your list plot as the first argument, the action function in the second argument with get the point that was clicked on in plot coordinates. You can write the action function to find the nearest pair in your list of data pairs and use the found pair to select the what you want to display.