Update/reload TGraph

Hi

Quick question:
Is there a way to reload a file into a TGraph object and how can I skip let’s say 20 lines?

Cheers,
delos

The TGraph constructor from a file does not have this kind of filtering built in:
root.cern.ch/doc/master/classTG … 4b6826a434

It is up to you to create the appropriate file from the original file skipping the lines you do not want.
That’s a few line of C

Thanks

That I can manage. Though, I reload files after a while but I don’t know how to update the graph.
I tried:

  • to delete the graph an replot it
  • modify points in the graph (a bit tricky anyway, since the number of data points may vary)

Cheers,
delos

If you delete it and recreate a new graph it should work

I do the following and loose my graph (see picture).

[code]
TCanvas *fCanvas = MyCanvas->GetCanvas();
fCanvas->cd();
fCanvas->Update();
fCanvas->Modified();
GraphPad->cd(1);

delete FScan[0];

FScan[0]=new TGraph("C:/root/test.txt");
FScan[0]->Draw();
fCanvas->cd();
fCanvas->Modified();
fCanvas->Update();
fCanvas->Modified();[/code]


It looks like you want the old and the new graph on the same plot. In that case you should not delete the old one. You create the new one and fill it with the subset of points you need.

Ok, but I do delete FScan[0]; and then new TGraph.
Shouldn’t this be enough?

Thnaks and cheers,
delos

Your example does not show enough to understand what you really want to do.
I understood that you would like to see FScan[0] and the new TGraph on the same plot.
If you delete FScan[0] it disappear …

Try:
FScan[0]->Draw(“AL”);
gPad->Modified(); gPad->Update();

Hi Pepe

Your solution is working and my graphs are back. Though, I still wonder why gPad->Update() aso works and GraphPad->Update() doesn’t.

@couet: basically I am loading saved plots with specific numbers. If I click “Next year” the plot of the next year should apear. In fact, the five plots are ONE but they are split into 5 pads for clarity (and our operators are used to it… then it cannot be changed :wink: ).
So I am clicking my self through the years…

Cheers,
delos