TGraph Drawn like TVectorD

[code]#include “TVectorD.h”
#include “TGraph.h”

TGraph *TVectorD2TGraph(TVectorD *v)
{
if (!v) return ((TGraph *)0); // just a precaution
TGraph *g = new TGraph( (2 * v->GetNoElements()) );
for (Int_t i = 0; i < v->GetNoElements(); i++) {
(g->GetX())[(2 * i)] = ((Double_t)i);
(g->GetX())[(2 * i + 1)] = ((Double_t)(i + 1));
(g->GetY())[(2 * i + 1)] = (g->GetY())[(2 * i)] = (*v)[i];
}
// g->Draw(“AL”);
return g;
}[/code] You can then “scale” the “X” coordinates of the points of the returned TGraph as you wish. See, for example, [url]Shifting TMultigraph on x-axis to the same starting point (and don’t forget [url]Shifting TMultigraph on x-axis to the same starting point

BTW. If you want to “scale” the “X” axis of the drawn histogram:
TH1D h = static_cast<TH1D>(gPad->FindObject(“TVectorD”));
you need to remember that it has “fix bin sizes” along “X”, so you can only modify “xmin” and “xmax” of its “X” axis (hence the “scaling function” must be linear and “xmax” must remain greater than “xmin”). See: [url]Can we shift histogram for several channels?