MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Version 6 graphics can be painfully slow

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84851] Re: Version 6 graphics can be painfully slow
  • From: thomas <thomas.muench at gmail.com>
  • Date: Wed, 16 Jan 2008 23:02:43 -0500 (EST)
  • References: <fmkerk$72g$1@smc.vnet.net>

Dear Szabolcs,

I do have a solution, if your data is continuous (e.g. a time course
of some sort; the important feature of which being that no x-value
appears twice), and regularly spaced. Then your data can be
represented by the y-values alone; x<first> and x<last> are sufficient
to represent the span of the data.

I frequently have to plot that sort of data.

I do this by reducing the number of points plotted to 1000 (which
roughly is the number of pixels on the screen, and therefore
sufficient). I divide my data into 1000 blocks, find the Min and Max
of each block, and then represent each block by a vertical line
between min and max. This looks basically indistinguishable from a
ListLinePlot on the original data. I can give you the code snippet if
you are interested.

If your data is not so well-behaved, you might try to convert your
list of 2D coordinates into a packed array (if it not already is one;
your sample random data already is)

newList=Developer`ToPackedArray[list]

and then use

Point@newList

instead of Point/@newList in your Graphics. This will speed up things
like you never would imagine.

"@" instead of "/@" may already increase the speed without packing the
array (in other words, they time it takes to pack the array might
outweigh the speed you gain in the plotting, but I doubt it). Compare
the speed differences:


data = Table[{Random[], Random[]}, {100000}]; (*This is packed*)
data1 = Developer`FromPackedArray[data];(*This is not*)

and then

Graphics[{PointSize[0.002], Point@data},   AspectRatio ->
Automatic] // Show

or

Graphics[{PointSize[0.002], Point@data1},  AspectRatio ->
Automatic] // Show

The packed array plots much faster!

Good luck!
Thomas

On Jan 16, 9:22 am, Szabolcs Horv=E1t <szhor... at gmail.com> wrote:
> In some cases, version 6 graphics can be painfully slow.  Consider this
> example:
>
> data = Table[{Random[], Random[]}, {100000}];
> Graphics[{PointSize[0.002], Point /@ data}, AspectRatio -> Automatic] //
> Show
>
> This used to work fine in version 5.2, but it takes forever to complete
> in version 6.0.1.  I have a dataset with about 250 000 points that I
> would like to plot, so this problem is really annoying ...
>
> The strange thing is that as soon as the graphic appears, resizing is
> fast and works fine (especially with antialiasing disabled).  So it is
> not the /drawing/ itself that takes so long.
>
> I really hope that these problems will be fixed in 6.1, but until then,
> does anyone have a suggestion for speeding this up?
>
> (At the moment I temporarily switch back to << Version5`Graphics`)
>
> Szabolcs



  • Prev by Date: Re: Don't understand behavior of ClearAttributes[Plus,Orderless]
  • Next by Date: Mouse operation, slider, dynamics, plot combination
  • Previous by thread: Re: Version 6 graphics can be painfully slow
  • Next by thread: Re: Version 6 graphics can be painfully slow