# Place histogram at given point in a canvas

Hi,
how do I place one or sevaral histograms at a given point in a canvas? What do I have to do replace the TBox in this example with a histogram?

``````  c = new TCanvas("c","c",400,400);
c->Range(-283,-714,108,204);
b = new TBox(-100,-300,100,100);
b->Draw()``````

I guess, that I have to create a new TPad, but I don’t know how to calculate the coordinates.

Cheers, J.

see example below

Rene

[code]{
TCanvas *c1 = new TCanvas(“c1”, “c1”,14,30,700,530);

// ------------>create a new pad p1
// pad coordinates are expressed in NDC [0,1] with respect to parent pad
p1->Draw();
p1->cd();
//define a range and create a low level primitive
p1->Range(-10,0,20,5);
TBox *box = new TBox(-6,1,18,4);
box->SetFillColor(kOrange);
box->Draw();
c1->cd();

p2->Draw();
p2->cd();
//when drawing the TF1 object, it will automatically compute
// the user coordinate range
TF1 *f = new TF1(“f”,“sin(x)/x”,0,10);
f->Draw();
}
[/code]

My problem seems to be, that I don’t know where to place the new Pad, if I want to place it at known user coordinates. Can I give the coordinates of a new TPad in user coordinates, or which method of the canvas converts user coordinates to NDC coordinates?

To convert from user coordinates (x,y) in pad, do

``` double u = (x-pad->GetX1())/(pad->GetX2()-pad->GetX1()); double v = (y-pad->GetY1())/(pad->GetY2()-pad->GetY1()); ```
Rene

This looks a little bit circuitously to me, but seems to be exactly what I need.
Thanks.