7
$\begingroup$

Using:

displaylength = 20000;
displayheight = 40;
length = 50000;
height = 40;
a = Table[RandomReal[], height, length];
Manipulate[
 ArrayPlot[a, ImageSize -> {1000, 200}, AspectRatio -> Full, 
 PlotRange -> {{1, displayheight}, {i, i + displaylength}}], {i, 1, 
 length - displaylength, 1}]

the output looks nice and the slider is very responsive:

enter image description here

But as soon as displayheight is set to 39, the output changes, is drawn very slow and the responsiveness of the slider is terrible:

Notice that displayheight is set to 39 below the plot

This is exactly the breaking point when the aspect ratio of the plot goes beyond 100.

What is the reason for this? Is it dependent on the graphic card? How to avoid it (without limiting the aspect ratio)?

p.s. The problem is still there in version 11. p.p.s. Running on 64bit Windows 7 using NVIDIA GeForce 210

$\endgroup$
  • $\begingroup$ Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Aug 15 '16 at 12:07
  • $\begingroup$ I get the same performance with displayheight=39. I am on windows 7 64 bit with a NVIDIA Quadro K4000 graphics card. Also works using 20 for displayheight. $\endgroup$ – Jack LaVigne Aug 15 '16 at 17:01
  • $\begingroup$ @JackLaVigne I need displayheight = 19 to trigger it in 10.1.0 under Windows. $\endgroup$ – Mr.Wizard Aug 15 '16 at 18:43
4
$\begingroup$

As a workaround you can use Image* functions:

displaylength = 20000;
displayheight = 40;
length = 50000;
height = 39;
a = Table[RandomReal[], height, length];

Manipulate[
  ImageResize[
     ImageTake[
       Image[a], {1, displayheight}, {i, i + displaylength}
     ], 
     {1000, 200}
  ], 
  {i, 1, length - displaylength, 1}
]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ (+1) I would add Magnification -> 1 into the Image for such purposes. In any case it is worth to mention this option here. $\endgroup$ – Alexey Popkov Aug 15 '16 at 23:01
  • $\begingroup$ (+1) Nice workaround. $\endgroup$ – skromnibog Aug 17 '16 at 7:01
  • 1
    $\begingroup$ For my purpose adding Sampling->"Constant" to ImageResize was required. Otherwise zooming into the display would not show tiles as it should. $\endgroup$ – skromnibog Aug 17 '16 at 9:54
1
$\begingroup$

In version 10.1.0 under Windows one can reduce the example to this:

a = RandomReal[1, {20, 600}];

Table[
  Graphics[Raster[a], ImageSize -> {600, h}, AspectRatio -> Full]
  , {h, {200, 210}}
] // Column

enter image description here

I cannot find a description of this transition in the documentation. I shall see if I can find anything else useful to note.

$\endgroup$
1
$\begingroup$

You may use the PixelConstrained option to speed up ArrayPlot in this instance.

displayheight = 39;
Manipulate[
 ArrayPlot[a, ImageSize -> {1000, 200}, AspectRatio -> Full, 
  PlotRange -> {{1, displayheight}, {i, i + displaylength}}, 
  PixelConstrained -> 4], 
 {i, 1, length - displaylength, 1}]

I'm not total certain why this happens but it appears that displayheight = 39 does not agree with ArrayPlot's default display options. If you explicitly set the pixel alignment with PixelConstrained then it has no difficulties working out where to paint the cells.

Hope this helps.

$\endgroup$
  • $\begingroup$ This doesn't appear to affect the underlying issue. For example with displayheight = 15; and PixelConstrained -> 20 I get the same transition to hard banding and the same slow-down while moving the slider. $\endgroup$ – Mr.Wizard Aug 16 '16 at 6:18
  • $\begingroup$ Agree, PixelContrained helps only in some setups of the parameters. In ArrayPlot[RandomReal[1, {20, 600}], ImageSize -> {600, 102}, AspectRatio -> Full, PixelConstrained -> 4] PixelConstrained is not helping. $\endgroup$ – skromnibog Aug 17 '16 at 7:06

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.