Histogram Marker bin positions

Hi all,

Im having a problem with the TAttMarker::SetMarkerStyle(Style_t) method. It seems when i use this method on a TH2F object the marker positions dont appear centrally in the bin (in x or y).

Does anyone know what im doing wrong? If anything?

Many thanks,
Matt

Are you plotting the TH2F as a scatter plot ?
can you send a small script showing what you are doing ?

Many thanks for the speedy reply. I have written a script that basically replects what im doing. I loaded and ran it in root 5.12.00e. If you view the histogram it produces in the file you can see the markers are at “random” positions within the bin(1,1) where they sit.

//To run:
//.L file.cpp
//th2ftest()
void th2ftest() {

TFile* file = new TFile(“th2ftest”, “RECREATE”);

TH1* h = new TH2F(“h”,“h”, 10, 0., 10., 10, 0., 10. );

for (Int_t ibin = 0; ibin <10>Fill(.5,.5);
}
h->SetMarkerStyle(2);
file->cd();
h->Write();
delete h;
delete file;
}

Thanks again,
Matt

In your script you do not draw the TH2F … What option are you using to plot it ?

If i run this script it writes the TH2F to file. I dont use “Draw()” anywhere.
The options used to draw are whatever the default ones are when i click on the histogram in TBrowser.

When you draw a TH2 without options it is drawn as a scatter plot. Some markers are drawn randomly in each bin. The number of makers drawn in each bin is proportionnal to the bin content.So the more makers are drawn the more dark the bin looks.

Okay. So maybe i’ll have to specify a draw option and write a TCanvas instead of a TH2F.

Thanks again.
Matt

No … this is not the way to go…
On the top right corner of a TBrowser you have a pull down menu called “Option” …change this option, it will be used when plotting an histogram when you click on it in the browser

The package being written will be used by others, not just myself (hopefully!) and so the histograms need to be immediately presentable and understandable without the user having to define their own draw options - unless they want to. For this purpose is a TCanvas the best option?

Matt

Before saving the histogram in a root file do :

h->SetOption(“col”);

it will be save with the drawing option COL and then when you will do h->Draw() it will be drawn with this option.

Brilliant. Thats just what i need.

Thank you very much for your time.
Matt