Removing boundary lines from TH1 subset histogram

Hi rooters,

I try to plot 2 histograms one (red line in the figure) being a subset of the other

Is there a way to remove the red lines at the beginning and the end of the “red” histogram ?

I also attached a minimal ROOT macro to generate this result

{
  TH1D * h = new TH1D ("", "", 100, 0, 100);
  const size_t nentry = 1000;

  for (size_t i = 0; i < nentry; ++i)
    {
      const unsigned int r = rand () % 100;
      clog << r << endl;
      h->Fill (r);
    }

  h->Draw ();

  const size_t start_bin = 20;
  TH1D * h2 = new TH1D ("","", 20, start_bin, start_bin+20);

  for (size_t i = 0; i < 20; ++i)
    {
      h2->SetBinContent (i, h->GetBinContent (start_bin+i));
    }

  h2->SetLineColor (kRed);
  h2->Draw ("same");
}

Thanks in advance for your help,
Xavier

Search for “][” in http://root.cern.ch/root/html/THistPainter.html
Try also: { TH1D *h = new TH1D("h", "h", 100, 0, 100); size_t nentry = 1000; for (size_t i = 0; i < nentry; ++i) { unsigned int r = rand() % 100; h->Fill(r); } h->DrawCopy(); size_t start_bin = 20; h->SetAxisRange(h->GetBinCenter(start_bin), h->GetBinCenter(start_bin + 20), "X"); h->SetLineColor(kRed); h->Draw("][ same"); }

Thanks Pepe, the “][” option works as expected. I read carefully the THistPainter documentation even the THistPainter source code and I didn’t notice this option. Thanks again,

Xavier