Re: Dynamic 2D ListLinePlot PlotRange
- To: mathgroup at smc.vnet.net
- Subject: [mg98301] Re: Dynamic 2D ListLinePlot PlotRange
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 3 Apr 2009 20:18:21 -0500 (EST)
- Organization: Uni Leipzig
- References: <gr4jkk$aap$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, data = Table[{x, Sin[x] + RandomReal[{-0.1, 0.1}]}, {x, 0, 2 Pi, 2 Pi/512}]; Manipulate[ ListLinePlot[data, PlotRange -> {{xmin, xmax}, All}], {{xmin, 0, "\!\(\*SubscriptBox[\"x\", \"min\"]\)"}, 0, 2 Pi}, {{xmax, 2 Pi, "\!\(\*SubscriptBox[\"x\", \"max\"]\)"}, 0, 2 Pi}] ? Regards Jens Bryce Schober 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? >