4
$\begingroup$

I was trying different colorfunctions, but don't get the RedLevel like the picture as follow:enter image description here My picture is like this, a greylevel one. enter image description here

$\endgroup$
  • $\begingroup$ Please post the code you are using. $\endgroup$ – Rohit Namjoshi Oct 17 at 14:54
6
$\begingroup$

In addition to the methods posted by KennyColnago, we also have Blend:

ArrayPlot[
 Table[Sin[x y],
  {x, -2, 2, 0.01},
  {y, -2, 2, 0.01}
  ],
 ColorFunction -> (Blend[{White, Red}, #] &)
 ]

Mathematica graphics

Or with Black (because I think that this is an equivalently valid interpretation of RedLevel):

ArrayPlot[
 Table[Sin[x y],
  {x, -2, 2, 0.01},
  {y, -2, 2, 0.01}
  ],
 ColorFunction -> (Blend[{Black, Red}, #] &)
 ]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ I just made a grayredlevel one today with my advisor, nice! $\endgroup$ – CA Trevillian Oct 18 at 7:47
4
$\begingroup$
redWhiteTones = RGBColor[1, #, #] &;
whiteRedTones = RGBColor[1, 1 - #, 1 - #] &;
blackRedTones = RGBColor[#, 0, 0] &;
redBlackTones = RGBColor[1 - #, 0, 0] &;

Row[ArrayPlot[Table[Sin[x y], {x, -2, 2, 0.01}, {y, -2, 2, 0.01}], 
      ColorFunction -> #, PlotLabel -> Style[#, Black, 20], ImageSize -> 300] & /@ 
  {redWhiteTones, whiteRedTones,  blackRedTones, redBlackTones}, Spacer[10]]

enter image description here

This is an alternative way to get the colors produced by Blend in C.E.'s answer, For example:

redWhiteTones /@ Range[0, 1, .1] ==  Blend[{Red, White}, #] & /@ Range[0, 1, .1]

True

blackRedTones /@ Range[0, 1, .1] == Blend[{Black, Red}, #] & /@ Range[0, 1, .1] 

True

$\endgroup$
3
$\begingroup$

If I use ArrayPlot, and make up some data, the grey level image looks like the following.

ArrayPlot[
    Table[Sin[x y], {x, -2, 2, 0.01}, {y, -2, 2, 0.01}],
          ColorFunction -> (GrayLevel[#] &)]

grey level image

A corresponding red level image could be written like this.

ArrayPlot[
    Table[Sin[x y], {x, -2, 2, 0.01}, {y, -2, 2, 0.01}],
          ColorFunction -> (Directive[Opacity[1 - #], Red] &)]

red level image

Alternatively, use the full form of Hue as follows.

ArrayPlot[
    Table[Sin[x y], {x, -2, 2, 0.01}, {y, -2, 2, 0.01}],
    ColorFunction -> (Hue[1, 1 - #, 1] &)]

To reverse the colour scaling, replace 1-# with # in ColorFunction.

$\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.