Plotting an implicit function f(x,y)=0

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 ?

You plot a 2D function so you get several iso value… that’s normal. You can also plot it as a surface using option surf.

You plot a graph so you get a X/Y plot … sounds ok for me.

BTW: use png images instead of jpeg …

But my question is: how can i just get one of the curves?
When i use the ‘surface’ option i get this figure:

that would be also ok, if i would know how to get the slice for z=0.

[quote=“couet”]
You plot a graph so you get a X/Y plot … sounds ok for me.[/quote]

Its just strange because its not coherent with the ‘S’-shape i am expecting

well, you had the one curve plot with TGraph ? …

I had one Plot with TGraph (see the second plot in my first post) but the result doesnt make sense to me.
Its not how the equation ‘0=tanh( [x+y]/t) -y’ is suppose to look like for 0<t<1.

What i am expecting looks like this:
http://www.wolframalpha.com/input/?i=y%3Dtanh((x%2By)%2F0.5)

You can specify the contours you want to see using SetContour:
root.cern.ch/root/html534/TH1.ht … SetContour

[quote=“couet”]You can specify the contours you want to see using SetContour:
root.cern.ch/root/html534/TH1.ht … SetContour[/quote]

Ok that works . thanks a lot

next step would be now that i have a list of x-values and root gives me the y-values that go with that contour.
Is there someone who knows if that is possible?

greetings,
alexander

what do you mean by “gives” ?