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.


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

 Array[If[EvenQ[#], 0, GCD[#, #2]] &, {20, 20}],
 ColorRules -> {0 -> Gray, 1 -> Black, _ -> White}

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.