Non-equidistant axis

Dear all,

I would to create a plot that has two X-asis, one at the bottom (as usual) and one at the top.
The one at the bottom is an inverse temperature (which is needed for things that are boltzman distributed).

The top axis, however, should have the corresponding temperatures in Kelvin, e.g. 300 K on the left, and 2 K on the right (as the bottom is an inverse temperature).

The top axis would thus have to have non-equidistant spacing for multiple integers.

Is there a solution for that?

Cheers,
Hendrik

You should plot a TGAxis on top, but that you found I guess…

What is the law defining the tick spacing ? 1/x ?
TGaxis provides something to position ticks according to a function but it is not always
suitable… it depends on your particular case.

Another possibility is to using alphanumeric labels…

Can you provide a small draft showing how your axis should looks like ?

Yes, I would like to use a TGaxis.

I attached a picture that illustrates the case:

On the bottom you see the inverse temperature in 1000/T (T in K). (lets call it x)
On the top you see the corresponding temperature. (T)
Hence, if the bottom axis (in x) goes from 2 to 10,
the top exis shall go from 500 K to 100 K.

We have T = 1000 / x, and dT = 1000 / x^2 *dx

=> int dT from T_0 to T_1 = int from x_0 to x_1 1000/x^2 * dx

=> T_1 - T_0 = 1000*(1/x_1 - 1/x_2).

An equidistant (say 100K) intervall on the top axis hence correponds to a distance in x of:

100 = 1000*(1/x_1 - 1/x_2)
=> x_2 = 1 / ( 0.1 - 1/x_1 )

delta x = x_2 - x_1 = 1 / ( 0.1 - 1/x_1 ) - x_1.

Any help on how to define positon on ticks and labels in appreciated!

may be the following example can help:

void axisfun()
{
   c1 = new TCanvas("c1","Examples of axis",10,10,700,700);
   c1->Range(0,0,100,100);

///   TF1 *f1 = new TF1("f1","x*x",1,10);
   TF1 *f1 = new TF1("f1","1.0-exp(-x)",1,10);
   TGaxis *a1 = new TGaxis(10,10,90,10,"f1",510);
   a1->Draw();

   TF1 *f2 = new TF1("f2","-x*x",1,10);
   TGaxis *a2 = new TGaxis(10,20,90,20,"f2",510);
   a2->Draw();

   TF1 *f3 = new TF1("f3","100*x*x",1,10);
   TGaxis *a3 = new TGaxis(10,30,90,30,"f3",510);
   a3->Draw();

   TF1 *f4 = new TF1("f4","x*x",1,10);
   TGaxis *a4 = new TGaxis(10,40,90,40,"f4",510);
   a4->Draw();

   TF1 *f5 = new TF1("f5","log(x)",1,10);
   TGaxis *a5 = new TGaxis(10,50,90,50,"f5",510);
   a5->Draw();

   TF1 *f6 = new TF1("f6","-log(x)",1,10);
   TGaxis *a6 = new TGaxis(10,60,90,60,"f6",510);
   a6->Draw();

   TF1 *f7 = new TF1("f7","10*log(x)",1,10);
   TGaxis *a7 = new TGaxis(10,70,90,70,"f7",510);
   a7->Draw();

   TF1 *f8 = new TF1("f8","x*x*x",1,10);
   TGaxis *a8 = new TGaxis(10,80,90,80,"f8",510);
   a8->Draw();

   TF1 *f9 = new TF1("f9","x*log(x)",1,10);
   TGaxis *a9 = new TGaxis(10,90,90,90,"f9",510);
   a9->Draw();
}

Thanks,

I now have this

[code]void axisfun()
{
c1 = new TCanvas(“c1”,“Examples of axis”,10,10,700,700);
c1->Range(0,0,110,110);

TF1 *f10 = new TF1(“f10”,“1/x”,500,50);
TGaxis *a10 = new TGaxis(10,100,90,100,“f10”,10011,"-");
a10->SetLineColor(4);
a10->Draw();

}[/code]

which is close to what I want.

But there are too many labels on the left hand side, as 500, 450, 300, … overlay.
Can I control which labels should be omitted ?

I will need to look at this.
Right now with this kind of axis there in one label per tick.
something should be done if they overlap.

Please have a look at the attachment to see the overlapping labels.

Yes I see that too … trying to see if TGAxis can be modified …

one way you can already apply now is to reduce the number of divisions:

TGaxis *a10 = new TGaxis(10,100,90,100,“f10”,503,"-");