# Generating multiple plots according to some rules

Let us assume I have two lists of the same lenght and in the form:

mesh ={{0.1, 0.3}, {0.1, 0.8}, {0.1, 1.3}, {0.6, 0.3}, {0.6, 0.8}, {0.6,1.3}, {1.1, 0.3}, {1.1, 0.8}, {1.1, 1.3}, {1.6, 0.3}, {1.6, 0.8}, {1.6, 1.3}};

colors={1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0}


I'd like to make a ListPlot with the values form mesh and make every point green if the corresponding point in colors is 1 or elese red. If it helps you can assume that there exists a function f that for every element of mesh gives the corresponding element color.

My idea was to generate all the plots separately and save them into some variable names and then just use Show to display them all at once. I tried implementing this with

Do[
If[f[k] == 1,
Symbol["plot" <> ToString[Flatten[Position[mesh, k]][[1]]]] =
ListPlot[{k}, PlotStyle -> Green],
Symbol["plot" <> ToString[Flatten[Position[mesh, k]][[1]]]] =
ListPlot[{k}, PlotStyle -> Red]], {k, mesh}]


but this gives me the error

Set::write: Tag Symbol in Symbol[plot1] is Protected.


and in general seems like a rather cluncky methode to get this done... Can anybody suggest a (more sophisticated) solution.

If I understand you correctly, you can use a Style wrapper to control the colors:

ListPlot[Thread @ Style[mesh, Lookup[{1->Green, 0->Red}, colors]]]


Or you can segregate the points using GroupBy:

ListPlot[
Lookup[
{1,0}
],
PlotStyle->{Green,Red}
]


Or you can use Point with a VertexColors option in Graphics:

Graphics[
{
PointSize[Medium],
Point[mesh, VertexColors -> Lookup[{1->Green, 0->Red}, colors]]
},
Axes->True, AxesOrigin->{0,0}
]