# Selecting interesting graph positions with a button press/click or something similar

Assume that I have a graphList as shown below (a simple working example).

graphList =
Show[Plot[x^2, {x, 0, 3.5}],
ListPlot[RandomInteger[{0, 10}, #],
PlotStyle -> Directive[Orange, PointSize[0.05]]],
PlotLabel -> Style[#, Red, Bold, 20]] & /@ Range[10];


Now, imagine that I want to manually go through each graph one by one and save interesting graphs by positions into separate lists. For example:

interestingList1 = {1, 3, 8};
interestingList2 = {4, 6};


However, I don't want to manually write down the numbers like that, as it is easy to make errors by miswriting the numbers and it's probaly a bit slow as well. So, I'm thinking about a method to add something to the graph (button or something) that allows me to save positions by simply clicking/pressing a button or using a similar method to add them to interestingList1 and interestingList2, which I can select. A button is just my idea. If you know a better way to do it, please suggest as well.

How can I do that?

You may store the different plots and then use "AppendTo" to fill the list with the chosen plots like:

graphList = {};
Column[{graph[#] =
Show[Plot[x^2, {x, 0, 3.5}],
ListPlot[RandomInteger[{0, 10}, #],
PlotStyle -> Directive[Orange, PointSize[0.05]]],
PlotLabel -> Style[#, Red, Bold, 20]],
Button["Save", AppendTo[graphList, graph[#]]]}] & /@ Range[10]

Dynamic[graphList]


We can use a combination of SetterBar, TogglerBar and PaneSelector

ClearAll[tB, indexSelector]

tB[Dynamic[$$w_], gl_, nc_ : 5] := TogglerBar[Dynamic[$$w],
Appearance -> "Horizontal" -> {Automatic, nc}]

SetAttributes[indexSelector, HoldFirst]

indexSelector[intl_, graphlst_, nc_ : 5] := (ClearAll @ intl;
Deploy @
DynamicModule[{$$z,$$il = Range @ Length @ intl, lbls = ToString /@ intl},
Column[{SetterBar[Dynamic[$$z], MapThread[Rule, {il, lbls}]], PaneSelector[ Table[With[{w = intl[[i]]}, tB[Dynamic[$$w], graphlst, nc]],
{$$i, 1, Length @ intl}], Dynamic[$$z]]},
Alignment -> Center]])


Examples:

graphList = Show[Plot[x^2, {x, 0, 3.5}],
ListPlot[RandomInteger[{0, 10}, #],
PlotStyle -> Directive[Orange, PointSize[0.05]]],
PlotLabel -> Style[#, Red, Bold, 20]] & /@ Range[10];

indexSelector[{interestingList1, interestingList2, interestingList3},
graphList]

Dynamic[{interestingList1, interestingList2, interestingList3}]


For more responsive interaction, rasterize the graphics in graphList:

rasterizedGraphList = Rasterize[#, ImageResolution -> 100, Background -> None,
ImageSize -> 180] & /@ graphList;

indexSelector[{interestingList1, interestingList2, interestingList3},
rasterizedGraphList, 4]

Dynamic[{interestingList1, interestingList2, interestingList3}]


Dynamic @ Style[Multicolumn[graphList[[interestingList2]], 2],
ImageSizeMultipliers -> {1, 1}]