1

I'm having trouble to create a plot with equipotential lines in gnuplot. Here is what I got so far:

f(x,y) = atan(y/(x+d))
d = 1.0

set view map
set isosamples 127, 127
unset surface 
set contour base
set cntrparam levels discrete pi/4.0

set xrange [ -2.0 : 2.0 ] noreverse nowriteback
set yrange [ -2.0 : 2.0 ] noreverse nowriteback

splot f(x,y) w l

It seems to work well, you can see the line with a gradient of 45°, except for the line at x=-1:

my plot result

I think it is because of the singularity in the argument of atan. In my final plot, there are even more similar singularities with similar lines not fitting into it.

Another thing: The lines should go through [-1,0], but you can clearly see a hole in the line. How can I get a clean plot without holes and wrong lines?

  1. How can i deal with this problem?
  2. If not, maybe there is another way of plotting equipotential lines?
  3. As last solution - what do you recommend, if gnuplot is not able to do this?

Thank you :)

nox
  • 252
  • 5
  • 18
  • you can try: `set samples 125` and `set isosamples 125, 125` to include singularity point. The line will be splitted to two parts – Stefan Oct 19 '16 at 20:57
  • This doesn't work for me. But it looks like, for a first workaround, i can combine the `set samples` and `set isosamples` with a piecewise defined function like `f(x) = abs(x+d)>1e-2 ? atan(y/(x+d)) : NaN`. Then I still get some strange holes, but at least these artifact lines are gone... Still looking for a solution, not a workaround :) – nox Oct 19 '16 at 21:35
  • I admit it is interesting, you can try to use `atan2()` instead of `atan()` or `arg(x+d +y*{0,1})` but it seems I missed something. Maybe it will be helpful for you. I am looking forward to see the solution. – Stefan Oct 19 '16 at 21:45

0 Answers0