Re: Dynamic 2D ListLinePlot PlotRange

*To*: mathgroup at smc.vnet.net*Subject*: [mg98280] Re: Dynamic 2D ListLinePlot PlotRange*From*: DrMajorBob <btreat1 at austin.rr.com>*Date*: Sun, 5 Apr 2009 06:34:19 -0400 (EDT)*References*: <200904030935.EAA11550@smc.vnet.net>*Reply-to*: drmajorbob at bigfoot.com

You haven't explained tmin or tmax, but ignoring that, here's some sample data and code to compute the minimum and maximum x values: test = RandomInteger[{1, 10000}, {2, 50, 2}]; minMax = Through[{Min, Max}@Flatten[test, 1][[All, 1]]] {52, 9885} If you want the first element to be no less than tmin and the second to be no more than tmax, you can do this: {curmin, curmax} = {tmin, tmax} = Sort@RandomInteger[{1, 10000}, 2] Apply @@@ Transpose@{{Max, Min}, Transpose@{{tmin, tmax}, minMax}} {5877, 7951} {5877, 7951} or the simpler {Max@#[[1]], Min@#[[2]]} &@Transpose@{{tmin, tmax}, minMax} {5877, 7951} Bobby On Fri, 03 Apr 2009 04:35:24 -0500, Bryce Schober <bryce.schober at dynonavionics.com> wrote: > I'm a bit of a newbie here, trying to build up some data visualization > tools. I've already gotten a ListLinePlot working well with slider to > adjust > xmin and xmax. I was hoping that I could set PlotRange to All for the Y > axis > and it would adjust for the Y-values in the dynamically specified x > range, > but no such luck. Is there some other way to not have to do the y-axis > range > calculation myself? > > I suppose some explanation of the dataset is desired. I have something > like: > { > {{x11,y11},{x12,y12},{x13,y13},...,{x1m,y1m}}, > {{x21,y21},{x22,y22},{x23,y23},...,{x2n,y2n}}, > } > , where the x values and lengths are heterogeneous between xy lists 1 > and 2 > > This makes the calculation of ymin and ymax very non-straightforward to > me, > and re-calculation unacceptably slow on 20k+ data points per list. The > dynamic x-axis plot scaling actually goes very smoothly, by using a > construct like: > > Show[ > ListLinePlot[data,PlotRange -> All,], > PlotRange ->Dynamic[{{curxmin, curxmax},All}], > ] > > I've tried various ways to get at the problem, and the closest I've > gotten > is something like: > > Map[ > {Min[#], Max[#]} &, > Map[ > (Select[ > #, > ( > #[[1]] > tmin > && #[[1]] < tmax > ) & > ]) &, > mydata > ][[All, All, 2]] > ] > > Which get me basically the result I want, but is really slow to evaluate, > making it undesirable as Dynamic[]. > > Any ideas? > -- DrMajorBob at bigfoot.com

**References**:**Dynamic 2D ListLinePlot PlotRange***From:*Bryce Schober <bryce.schober@dynonavionics.com>