Hello members of the ROOT-board,
I am trying to plot a function of the form f(x,y)=0 with ROOT. But i havent been very successfull with that.
For example the funcion: 0= tanh([x+y]/t) - y
http://www.wolframalpha.com/input/?i=plot+y%3Dtanh%28+%28x%2By%29%2F0.4%29+
(I know that i can solve this equation for x -> x=t*arctanh(y) - y , but i hoped this works as an example)
I tried several things:
1)
import ROOT as rt
t=0.395
def function(self,x,par):
return( rt.TMath.TanH((x[0]+x[1])*par[0])-x[1])
fkt=rt.TF2('harrison-model2',function,-1,1,-1,1,1)
fkt.SetPaarameter(0, (1/t))
fkt.Draw('')
As a result i get:
What is already ok, but i just need the ‘S’ that goes through the point (x,y)=(0,0).
But the most confusing thing is the plot i get, when i use the following code:
import ROOT as rt
import numpy as np
t=0.395
def function(self,x,par):
return( rt.TMath.TanH((x[0]+x[1])*par[0])-x[1])
fkt=rt.TF2('harrison-model2',function,-1,1,-1,1,1)
fkt.SetPaarameter(0, (1/t))
n=100
x=np.zeros(n)
y=np.zeros(n)
for i in range(n):
x[i]=-1 + 2*(i/float(n))
y[i]=fkt.Eval(x[i])
gr=rt.TGraph(n,x,y)
gr.Draw('AL')
the plot looks like this:
Does someone know what i am doing wrong ?