12
$\begingroup$

Bug introduced in 7.0 or earlier, and persisting through 10.1 or later (OSX 10.10.2)


Consider the following code:

jet[u_?NumericQ] := 
  Blend[{{0, RGBColor[0, 0, 9/16]}, {1/9, Blue}, {23/63, 
      Cyan}, {13/21, Yellow}, {47/63, Orange}, {55/63, Red}, {1, 
      RGBColor[1/2, 0, 0]}}, u] /; 0 <= u <= 1;
(* jet function get from http://stackoverflow.com/a/9321152/1363677*)
caxis[x_, {min_, max_}] := 
  If[x < min, jet[0], If[x > max, jet[1], jet[(x - min)/(max - min)]]];

data1 = Table[
   Sinc[x*y] + RandomReal[{0., 0.2}], {x, -2 Pi, 2 Pi, 0.05}, {y, -2 Pi, 2 Pi, 0.05}];
data2 = Table[
   Sinc[x*y] + RandomReal[{0., 0.2}], {x, -2 Pi, 2 Pi, 0.02}, {y, -2 Pi, 2 Pi, 0.02}];

Row[{Graphics[Raster[data1, ColorFunction -> (caxis[#, {-0.5, 2}] &)],
    ImageSize -> 200],
  Graphics[Raster[data2, ColorFunction -> (caxis[#, {-0.5, 2}] &)], 
   ImageSize -> 200],
  Graphics[Raster[data2, ColorFunction -> "BlueGreenYellow"], 
   ImageSize -> 200]}]

It gives the output:

enter image description here

Why is the second plot blank?

If the dynamic updating is turned off, all of the three are blank.

enter image description here

Why does Mathematica behave like this? I'm using OSX 10.8.4 on a Macbook Air with 1.7 GHz Intel Core i5 and 4GB memory.

$\endgroup$
19
  • $\begingroup$ You should certainly indicate what version and OS you're working with for this type of question. The code works fine for me in version 9.0.0 on Mac OSX 10.7.4. $\endgroup$ Jun 20, 2013 at 17:21
  • $\begingroup$ I'm using OSX 10.8.4. $\endgroup$ Jun 20, 2013 at 17:29
  • 2
    $\begingroup$ this is the issue with what was originally my wavelet scalogram exporting $\endgroup$
    – amr
    Jun 20, 2013 at 20:11
  • 1
    $\begingroup$ Possibly related to this question. $\endgroup$ Jun 20, 2013 at 21:41
  • 1
    $\begingroup$ Identical behavior observed here on 7.0.1, 8.0.4, and 9.0.1, on Windows 2003 x64. Middle plot is missing in all cases. $\endgroup$ Jun 22, 2013 at 2:34

1 Answer 1

8
$\begingroup$

Label this a most bizarre bug -- I can reproduce the problem (v9.0.0.0) -- the fix, change all those integer fractions in Blend to decimals..

This fails:

jet[u_?NumericQ] :=  Blend[{{0, RGBColor[0, 0, 1/9]}, {1, Red}}, u] /; 0 <= u <= 1

This works

jet[u_?NumericQ] := Blend[{{0, RGBColor[0, 0, 0.11111111]}, {1, Red}}, u] /; 0 <= u <= 1

Edit: another curiosity.. this should be the same (I think..) normalising the values before passing to the color function.

Graphics[Raster[data1, Automatic, {-.05, 2}, 
         ColorFunction -> (caxis[#, {0, 1}] &)], ImageSize -> 200]

Although it works, the colors are substantially different.

$\endgroup$
2
  • $\begingroup$ neither works with dynamic updating off. $\endgroup$
    – george2079
    Jun 20, 2013 at 18:15
  • 1
    $\begingroup$ I agree this is a bug (+1). It also disappears when I remove the RandomReal from the definition of the data. $\endgroup$
    – Jens
    Jun 20, 2013 at 18:22

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.