4
$\begingroup$

Bug introduced in 10.0.0 and fixed in 10.0.1


I have encountered two situations where Mathematica 10 is mishandling the outer pixels of plainly simple objects.

I input this:

Rasterize[Graphics[{}, Background -> Black, ImageSize -> {19, 19}]]

It should basically create a 19x19 pixel black square, but instead I get this:

Extra white image

If you select the image you will see an extra white pixel row on the top. Indeed, this is because the ImageDimensions[%] gives {19, 20}. A similar problem occurs with some other pixel sizes.


A similar effect takes place in barlegends:

GraphicsRow[{BarLegend[{"DeepSeaColors", {0, 1}}], BarLegend[{"DeepSeaColors", {0, 1}}, 
  LegendLayout -> "ReversedColumn"]}]

These are two bar legends going from 0 to 1, but the second one is reversed. The images look like this:

enter image description here

Here, the regular bar legend is okay, but the reversed one misses a thin grey line on one side.

Questions: Is it a bug? Does is happen only on my machine (Ubuntu 14)? Is it fixable (especially for the Legends)?

$\endgroup$
  • $\begingroup$ I got {19, 19} in MMA 10. $\endgroup$ – seismatica Aug 19 '14 at 11:00
  • $\begingroup$ @seismatica, which is interesting, thank you! $\endgroup$ – Alexey Bobrick Aug 19 '14 at 11:51
  • $\begingroup$ I can not reproduce what you report with V10 running on OS X. $\endgroup$ – m_goldberg Aug 19 '14 at 11:55
  • 1
    $\begingroup$ @AlexeyPopkov, I am using Ubuntu 14.04.1 and Mathematica 10.0, all together with NVIDIA Quadro 2000 card. $\endgroup$ – Alexey Bobrick Aug 20 '14 at 8:40
  • 1
    $\begingroup$ This works for me on V10.0.1 $\endgroup$ – Michael E2 Aug 8 '15 at 18:44
5
$\begingroup$

I was able to isolate the problem with BarLegend in v.10.0.0. Yes, it is clearly a bug.

Let us see the how the thin grey lines are implemented:

Cases[
 ToBoxes[BarLegend[{"DeepSeaColors", {0, 1}}, 
   LegendLayout -> "ReversedColumn"]], _LineBox, Infinity]
{LineBox[
  NCache[{{-(15/2), 225/2}, {15/2, 225/2}, {15/
     2, -(225/2)}, {-(15/2), -(225/2)}}, {{-7.5, 112.5}, {7.5, 
     112.5}, {7.5, -112.5}, {-7.5, -112.5}}]], 
 LineBox[{{7.5, 112.5}, {7.5, -112.5}}], 
 LineBox[{{{7.5, 112.5}, Offset[{4., 0}, {7.5, 112.5}]}, {{7.5, 67.5},
     Offset[{4., 0}, {7.5, 67.5}]}, {{7.5, 22.5}, 
    Offset[{4., 0}, {7.5, 22.5}]}, {{7.5, -22.5}, 
    Offset[{4., 0}, {7.5, -22.5}]}, {{7.5, -67.5}, 
    Offset[{4., 0}, {7.5, -67.5}]}, {{7.5, -112.5}, 
    Offset[{4., 0}, {7.5, -112.5}]}}], 
 LineBox[{{{7.5, 101.25}, 
    Offset[{2.5, 0.}, {7.5, 101.25}]}, {{7.5, 90.}, 
    Offset[{2.5, 0.}, {7.5, 90.}]}, {{7.5, 78.75}, 
    Offset[{2.5, 0.}, {7.5, 78.75}]}, {{7.5, 56.25}, 
    Offset[{2.5, 0.}, {7.5, 56.25}]}, {{7.5, 45.}, 
    Offset[{2.5, 0.}, {7.5, 45.}]}, {{7.5, 33.75}, 
    Offset[{2.5, 0.}, {7.5, 33.75}]}, {{7.5, 11.25}, 
    Offset[{2.5, 0.}, {7.5, 11.25}]}, {{7.5, 0.}, 
    Offset[{2.5, 0.}, {7.5, 0.}]}, {{7.5, -11.25}, 
    Offset[{2.5, 0.}, {7.5, -11.25}]}, {{7.5, -33.75}, 
    Offset[{2.5, 0.}, {7.5, -33.75}]}, {{7.5, -45.}, 
    Offset[{2.5, 0.}, {7.5, -45.}]}, {{7.5, -56.25}, 
    Offset[{2.5, 0.}, {7.5, -56.25}]}, {{7.5, -78.75}, 
    Offset[{2.5, 0.}, {7.5, -78.75}]}, {{7.5, -90.}, 
    Offset[{2.5, 0.}, {7.5, -90.}]}, {{7.5, -101.25}, 
    Offset[{2.5, 0.}, {7.5, -101.25}]}}]}

Let us visualize them:

Graphics[%]

graph

We see that the left line is simply absent. Why? Because the second line LineBox[{{7.5, 112.5}, {7.5, -112.5}}] should have negative X coordinates in order to be placed on the left:

Graphics[{Line[NCache[{{-(15/2), 225/2}, {15/2, 225/2}, {15/2, -(225/2)}, {-(15/2), -(225/2)}}, {{-7.5, 112.5}, {7.5, 112.5}, {7.5, -112.5}, {-7.5, -112.5}}]], 
Line[{{-7.5, 112.5}, {-7.5, -112.5}}]}]

gr

So the source of the problem is now clear: the developer just forgot to change the sign of the coordinates of this line when implemented LegendLayout -> "ReversedColumn" on the basis of already implemented LegendLayout -> "Column".

$\endgroup$
  • $\begingroup$ Greatly many thanks for clear analysis! I suppose, it also proves that the issue with legends is independent from the one with the boundary pixels. I will report is to Wolfram support therefore. $\endgroup$ – Alexey Bobrick Aug 20 '14 at 8:38
  • $\begingroup$ Yes, it certainly proves that these are completely independent issues. $\endgroup$ – Alexey Popkov Aug 20 '14 at 8:40
  • $\begingroup$ It was actually the legend issue which concerned me the most, so I mark your answer accepted. If there is more input from Wolfram support, I will add it into the question section. Thanks again! $\endgroup$ – Alexey Bobrick Aug 20 '14 at 8:51

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.