TGraph limiting the number of points displayed

I have an application that I have put together that uses a TGraph. I allocate arrays for the x and y in this 2 dimensional graph. The data come in realtime and per second I update the TGraph, using Draw(“LP”).

Well the TGraph behaves as it should by drawing all the points even
the ones not yet filled. Is there a way I can tell TGraph to draw a subset
of the points allocated to it?
Regards
Chris

Use TGraph::DrawGraph

Rene

So using drawgraph, do I do the following?

Elsewhere in the code I do a tg = new TGraph(Npoints) with the total number of points I intend to use.

In the update function it appears that I would have to do something like

Double_t *x = tg->GetX();
Double_y *y = tg->GetY();
tg->DrawGraph(NumberPoints2Draw, x,y);

since there doesn’t appear to be a method without x and y as input or
is it sufficient to put in x and y as null?

Chris

This is correct.

In the CVS version, you can call
mygraph.DrawGraph(n)
to draw only the first n points of the graph.

Rene

Hi,
Does point number on your plots only increase
or you wish firstly draw 10 points, then only 5?
There is a thread on a similar issue in the roottalk mail list:
http://root.cern.ch/root/roottalk/roottalk04/2547.html

mygraph.DrawGraph(n) creates a new graph thus it is significaly
slower than new TGraph::SetPoint() implementation.
Although a graph with external x-y arrays can be useful.


Max