1
$\begingroup$

I have de following array:

size=5;
Initial = RandomInteger[{0, 1}, {size, size}]*2 - 1;

to visualize it I use the following code:

ArrayPlot[Initial, ColorRules -> {1 -> White, -1 -> Black}]

I would like to highlight some points of the arrangement in the figure, for example:

{{4, 1}, {4, 3}, {3, 1}, {5, 1}, {4, 2}, {3, 3}, {4, 2}, {4, 4}}

How would that be done?

$\endgroup$
  • $\begingroup$ You can give a list of colors to array plot using Initial/.{1->White,-1->Black} and then wrap this in ReplacePart ArrayPlot[ ReplacePart[ Initial /. {1 -> White, -1 -> Black}, {{4, 1}, {4, 3}, {3, 1}, {5, 1}, {4, 2}} -> Red ] ]. Is this what you're looking for? You could also generate the colors explicitly using initColor=RandomChoice[{White,Black},{size,size}] and then use ReplacePart. $\endgroup$ – N.J.Evans Nov 12 '18 at 19:42
1
$\begingroup$
size = 5;
SeedRandom[1]
Initial = RandomInteger[{0, 1}, {size, size}]*2 - 1;
parts = {{4, 1}, {4, 3}, {3, 1}, {5, 1}, {4, 2}, {3, 3}, {4, 2}, {4,  4}};

ArrayPlot[MapAt[Red &, Initial, parts],  ColorRules -> {1 -> White, -1 -> Black}]

enter image description here

Replace Red& with RandomColor[]& to get

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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