2
$\begingroup$

I want to show even rows in an array in gray, and non-even rows in black/white.

ArrayPlot[Array[GCD, {20, 20}], 
 ColorFunction -> (If[# == 1, Black, White] &), 
 ColorFunctionScaling -> False]

I don't know how to specify this from ColorFunction.

$\endgroup$
1
$\begingroup$

Assign a special value to rows that are even and then use ColorRules or ColorFunction. Here I demonstrate ColorRules:

ArrayPlot[
 Array[If[EvenQ[#], 0, GCD[#, #2]] &, {20, 20}],
 ColorRules -> {0 -> Gray, 1 -> Black, _ -> White}
 ]
$\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.