This Seems like it should be relatively straight-forward, but I am struggling to find an answer. I would like to color each ArrayPlot in a GraphicsGrid by its Total. I can get the grid of ArrayPlots, but all of my efforts to assign color on the basis of Total have failed. Here is what I have at this juncture.

list = {0, 1}
b2 = Tuples[list, 4]
nn = Length[b2]
b2sort = Sort[b2, Total[#1] < Total[#2] &]
  Table[ArrayPlot[ ArrayReshape[b2sort[[n]], {2, 2}], Mesh -> All, 
    ImageSize -> 1 -> 25], {n, nn}], 4], PlotLabel -> "stuff"]

Ideally, each array that was produced would be given a unique color (for the entire array) that depended upon the total for that array (i.e., the numbers 0, 1, 2, 3 or 4). Any color function at this juncture would be fine. The idea is that all arrays with total=0 would be a unique color, all with total=1 would be a different unique color, etc.

Any help would be appreciated.

  • $\begingroup$ what is the value of var nn? $\endgroup$ – J42161217 Apr 23 '19 at 20:45
  • $\begingroup$ My apologies-- I meant to make that self-standing. nn is the number of elements in the set generated by Tuples. I have modified the code to put that crucial bit of information in. $\endgroup$ – d3e5560 Apr 23 '19 at 21:08

is this what you are looking for?

nn = Length[b2]

enter image description here

  • 1
    $\begingroup$ Yes-- that is exactly what I was looking for. Thanks- I learned something super helpful here! $\endgroup$ – d3e5560 Apr 23 '19 at 21:09
  • $\begingroup$ I'm glad I helped! Also keep in mind that by changing the first value of ColorData , you are changing color schemes $\endgroup$ – J42161217 Apr 23 '19 at 21:14

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.