I am making a RGB color function which assigns an RGB color to each point in the plane. To check if it does what I think it should do (i.e. debugging it), it is helpful to be able to plot the function to see how the problematic areas are arising. How can I plot this function? i.e. is there something along the lines of

  • $\begingroup$ closely related: 50461 $\endgroup$
    – Kuba
    Jun 15, 2014 at 8:38

1 Answer 1

cf = Function[{x, y}, ColorData["Rainbow"][Mean@{x, y}]];
RegionPlot[True, {x, 0, 10}, {y, 0, 10}, ColorFunction -> cf];

enter image description here

  • $\begingroup$ wait - if you change the plot range, nothing happens - what's going on? $\endgroup$ Jun 15, 2014 at 2:55
  • $\begingroup$ Oh it just needs to be rescaled. ColorData domains are {0,1} $\endgroup$
    – mfvonh
    Jun 15, 2014 at 3:03
  • $\begingroup$ and there's no other way around it? - hold on - this has the same problem, and doesn't use ColorData: cf = Function[{x, y}, RGBColor[x, y, 0]]; $\endgroup$ Jun 15, 2014 at 3:06
  • $\begingroup$ RGBColor also takes values in the domain {0,1}. If you have your domain you can just divide by a constant to get the values in that range. $\endgroup$
    – mfvonh
    Jun 15, 2014 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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