Histogram

Hi ROOTers!!! :slight_smile:
I have need your help for what concerne histogram [-o<

1)It is possible draw a histogram similar to a graph, with only the point(marker), without the columns?

  1. How can I set the errorbars? I kow that to draw the errorbars the command is:
    my_hist->Draw(“E1”) , but for set the error for each point? if it is possible xerrors and yerrors, and maybe asymmetrical errors, xerror hight and x error low.

  2. Is normal that when i declare an histogram, then the result is: (class TH1F *) 0x16dadf0 ??

  3. It is possible in ROOT 6 draw a histogram with data from dat files?

Thank you very much :wink:

  1. Have you tried the P draw option? You can see all details here root.cern.ch/doc/master/classTHistPainter.html
  2. What is the exact definition of a “x error” for an histogram?
  3. It could well be.
  4. What is exactly the format of these “dat files”?

Thank you very much for the answer and sorry if I was not clear
What I mean with x error and y error is the error on the measures of the data.
And the dat file I mean the txt file with more columns of data.

Thank you :wink:

Posting a small example showing the problem is very often the best explanation you can provide :slight_smile:

yes sorry, you are right

This is an example: I have 8 columns with x, y deviation x, deviation y, hight error x, low error x, hight error y and low error y

x y dx dy err_h-x err_l-x err_h-y err_l-y
9.8 0.1 0.01 0.01 9.9 9.8 0.12 0.11

I would like produce a histogram using the data from file (x and y) ad if it is possible also with errors.

Thank you :wink:

It looks like your binning might not be regular…
So you will have to read this file using normal C++ code.
And then you will need to use
root.cern.ch/doc/master/classTH … 0f36b4c62d
to book the histogram.

Waht do you mean with “your binning might not be regular” ?

That is just a guess. You have a table with x values (hopefully in increasing order). This x array will define your binning. If the distance between each x value is same, then you will have a regular binning and you can use the normal constructor. But given the fact it seems you have le low boundary of each bin, having non regular binning is possible. That is why I said your binning “might not be regular”… and in that case you can use the constructor I was referring to in my previous post.

ohh yes it isn’t regular… but if it is regular i culd draw an histogram direct from file?

No you need to read the file any, and create the histogram from the data you read.
See the possible constructors here:

root.cern.ch/doc/master/classTH … 0f36b4c62d

Looking at your “x y dx dy err_h-x err_l-x err_h-y err_l-y”, I would say you are asking for: TGraphAsymmErrors
Or … try somethign like this: TTree *t = new TTree("t", "a tree"); t->ReadFile("DataFile.txt", "x/D:y:dx:dy:err_h_x:err_l_x:err_h_y:err_l_y"); and then, for example:
t->Draw(“x”);
t->Draw(“y”);
t->Draw(“y:x”);

Ok, it is only for toknow if it is possible draw histogram from files, becaus I have saw this
sft.its.cern.ch/jira/browse/ROO … %20file%22

Pepe Le Pew, thank you but I have need a histogram, not Graph

The ROOT-5532 “Cannot draw histogram from file” bug report has NOTHING to do with what you want to achieve.

Ah ok I have understood…
so I have to store the data in a list or vector with C++ command and then with a cycle “for”, put them in histogram?

I have a problem, maybe a stupid problem, but I am a very beginner :blush: #-o

I’m trying to produce a macro that produce a simple histogram, for example:

{
TH1F *h1 = new TH1F(“h1”, “h1 title”, 100, 0, 10);
Int_t px=1;
Int_t py=1;
for (Int_t i = 0; i < 10; i++) {
px= px+i;
py=py+i;
hpxpy->Fill(px,py);
}

hpxpy->Draw(“HISTE1”)
}

But don’t work…why??

Well … you declare h1 and then you fill hpxpy …:frowning:

Ohhh yes you are right #-o #-o #-o

but also like this don’t work very well:

{
TH1F *h1 = new TH1F(“h1”, “h1 title”, 100, 0, 10);
Int_t px=1;
Int_t py=1;
for (Int_t i = 0; i < 10; i++) {
px= px+i;
py=py+i;
h1->Fill(px,py);
}

h1->Draw(“HIST”)
}

Draw the bar only for: 1,2 4 and 7… instead should draw a bars for all number from 1 until 10.

Thats the definition of an histogram… do a TGraph instead. Or fill the intermediate bins.

Sorry but if the bins are 10, and the x are 10, 1 each bin and should draw 10 bar…no?