MathGroup Archive 2007

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

Search the Archive

Re: Unbearably slow plotting (v6)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79747] Re: Unbearably slow plotting (v6)
  • From: thomas <thomas.muench at gmail.com>
  • Date: Fri, 3 Aug 2007 06:30:16 -0400 (EDT)
  • References: <f8f25i$soq$1@smc.vnet.net>

I feel that there are two sorts of discussions going in in this
thread. One is about the fact that plotting in v6.0 and v6.0.1 is
significantly slower than it was in 5.2, at least when plotting a
large number of data points. It seems that (almost) everybody can
agree to that. The second is how to downsample the data to circumvent
this problem.

A remark to topic 1:
As first pointed out by Murray Eisenberg, v5.2 is indeed slower than
what the "Timing" output suggests - part of the plot keeps appearing
even after the Timing result has been printed. When I first read this,
I was surprised, because this was not the case on my system, the whole
plot appeared quite fast, basically at once. I then figured out why: I
have set the PlotJoined option to True by default. In this mode,
Mathematica plots only lines connecting the data points, but not the
symbols representing the points themselves. For some reason, this is
fast! With PlotJoined -> False, the symbols are plotted, and rendering
those takes a long time indeed, also in 5.2.
Nevertheless, in v.6, ListPlot with the option Joined->True, or
ListLinePlot, are still horribly slow.

A remark about the downsampling issue:
First of all, I still think it should not be necessary to downsample
at all, if one simlpy wants to get a quick overview of the data. It is
quiet annoying that the performance in the "upgrade" is worse than it
was before.
Nevertheless, I wanted to give my two cents about how I do my
downsampling, while still avoiding the problem of loosing outliers.
Because this is indeed the problem with most downsampling techniques,
as pointed out by many in this thread. What I do is that I partition
my data trace into as many segments (say 1000) as I want points to be
plotted, and take the Min and the Max of each segment. That will be my
new data (which actually consists of twice as many points as
segments). The data trace is then essentially a zig-zag line which
goes up and down to the Min and the Max of the segments (as mentioned
above, I use PlotJoined->True as default). If the number of segments
is on the order of screen-pixels of the plot, the plot looks pretty
much the same as when plotting the original data.

Here is the code:
"p" is the number of segments I want
"data" is a 2-dim array; each row contains one original data trace to
be plotted
"len" is a vector containing the lengths of the data traces (usually
they are all the same)

plotData = Partition[#, Round[Min@len/p]] & /@ data;  plotData =
Flatten[Transpose[{Min /@ #, Max /@ #}]] & /@ plotData;

So, this works fine, plotting is fast, IF the number of traces I want
to plot is not too large (I downsample each trace, but I overlay many
traces. This can add up to many points again that need to be plotted).

Thanks for your attention!
Thomas



  • Prev by Date: Re: Paul Abbott Chebyshev Article
  • Next by Date: Re: If a*b=c/d, then a=c/bd, How do i do this in Mathematica?
  • Previous by thread: Re: Unbearably slow plotting (v6)
  • Next by thread: Re: How to return a mixture of vectors and matrices from compiled functions