5

Observing this LaTeX example: I draw, with the gnuplot environment, one implicit curve (conic), a horizontal line and a vertical line (axes through the origin). I do not understand the result: the implicit fonction and also straight lines are not centered on the grid! I do not how to resolve this problem. Who can help me?

Here, the entire file:

\documentclass[11pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{gnuplottex}
\usepackage[francais]{babel}

%\usepackage{tikz, pgfplots}   

\usepackage{geometry}
\geometry{top=2cm, bottom=2cm, left=2cm, right=2cm}
% ------------------------------------------
\begin{document}

\begin{center}
\begin{gnuplot}[ scale=1.5]
# paramètres
    phi = (38)*pi/180
    g = 2
    D = (0)*pi/180
    I = pi/2
    delta = 23.44*pi/180
# coefficients de la conique f(x,y)=0
    A = sin(delta)**2-cos(phi)**2*sin(D)**2
    B = sin(2*phi)*sin(D)*sin(I)+cos(phi)**2*sin(2*D)*cos(I)
    C = sin(delta)**2-(sin(phi)*sin(I)+cos(phi)*cos(D)*cos(I))**2
    D = g*(cos(phi)**2*sin(2*D)*sin(I)-sin(2*phi)*sin(D)*cos(I))
    E = g*(sin(2*phi)*cos(D)*cos(2*I)+sin(2*I)*(sin(phi)**2-cos(phi)**2*cos(D)**2))
    F = g**2*( sin(delta)**2-sin(phi)**2*cos(I)**2-cos(phi)**2*cos(D)**2*sin(I)**2+1/2*sin(2*phi)*cos(D)*sin(2*I))
# déclaration de la fonction implicite
    f(x,y)=A*x**2+B*x*y+C*y**2+D*x+E*y+F
# quelques reglages
    set cntrparam levels discrete 1.0
    set isosamples 1500,1500
    set xrange [-10:10]
    set yrange [-10:10]
    set title '$ax^2+bxy+cy^2+dx+ey+f=0$'
    set ylabel '$y$'
    set xlabel '$x$'
    set size ratio 1
    set nogrid
    # show size
    show offsets
    set view 0,0
    set cntrparam bspline
    set contour base
    unset surface
    set table 'implicite.dat'
    splot f(x,y), x, y
    unset table
# représentation graphique de la fonction implicite
    plot 'implicite.dat'  notitle w l
\end{gnuplot}
\end{center}
\end{document}
egreg
  • 1,121,712
DK06100
  • 471

2 Answers2

3

Here is a solution with PSTricks. Run it with latex->dvips->ps2pdf or with xelatex

\documentclass[pstricks,border=0bp,12pt,dvipsnames]{standalone}
\usepackage{pst-func}
\begin{document}

\psset{unit=0.6}
\begin{pspicture*}(-10.5,-10.5)(10.5,10.5)
  \psaxes[Dx=2,Dy=2]{->}(0,0)(-10,-10)(10,10)
  \psplotImp[algebraic,linecolor=red,linewidth=1.5pt](-11,-11)(11,11)[
      /phi 38 DegtoRad def
    /g 2 def
    /D 0 RadtoDeg def
    /I PI 2 div def
    /delta 23.44 DegtoRad def
    ]{%
    (sin(delta)^2-cos(phi)^2*sin(D)^2)*x^2
   +(sin(2*phi)*sin(D)*sin(I)+cos(phi)^2*sin(2*D)*cos(I))*x*y
   +(sin(delta)^2-(sin(phi)*sin(I)+cos(phi)*cos(D)*cos(I))^2)*y^2
   +(g*(cos(phi)^2*sin(2*D)*sin(I)-sin(2*phi)*sin(D)*cos(I)))*x
   +(g*(sin(2*phi)*cos(D)*cos(2*I)+sin(2*I)*(sin(phi)^2-cos(phi)^2*cos(D)^2)))*y
   +g^2*( sin(delta)^2-sin(phi)^2*cos(I)^2-cos(phi)^2*cos(D)^2*sin(I)^2
       +1/2*sin(2*phi)*cos(D)*sin(2*I))}
\end{pspicture*}

\end{document}

enter image description here

3

With the command

set cntrparam levels discrete 1.0

you select a single contour at z=1, so your horizontal and vertical line cross at (1,1). Using set cntrparam levels discrete 0.0 should give you the expected result. Here is a working gnuplot script. The behavior is completely unrelated to gnuplottex:

phi = (38)*pi/180
g = 2
D = (0)*pi/180
I = pi/2
delta = 23.44*pi/180
# coefficients de la conique f(x,y)=0
A = sin(delta)**2-cos(phi)**2*sin(D)**2
B = sin(2*phi)*sin(D)*sin(I)+cos(phi)**2*sin(2*D)*cos(I)
C = sin(delta)**2-(sin(phi)*sin(I)+cos(phi)*cos(D)*cos(I))**2
D = g*(cos(phi)**2*sin(2*D)*sin(I)-sin(2*phi)*sin(D)*cos(I))
E = g*(sin(2*phi)*cos(D)*cos(2*I)+sin(2*I)*(sin(phi)**2-cos(phi)**2*cos(D)**2))
F = g**2*( sin(delta)**2-sin(phi)**2*cos(I)**2-cos(phi)**2*cos(D)**2*sin(I)**2+1/2*sin(2*phi)*cos(D)*sin(2*I))
# déclaration de la fonction implicite
f(x,y)=A*x**2+B*x*y+C*y**2+D*x+E*y+F
# quelques reglages
set cntrparam levels discrete 0.0
set isosamples 1500,1500
set xrange [-10:10]
set yrange [-10:10]
set size ratio 1
set cntrparam bspline
set contour base
unset surface
set table 'implicite.dat'
splot f(x,y), x, y
unset table
# représentation graphique de la fonction implicite
plot 'implicite.dat'  notitle w l

and the result with gnuplot 4.6.5:

enter image description here

Christoph
  • 16,593
  • 1
  • 23
  • 47
  • In fact, I use gnuplot Version 4.4 patchlevel 3 on my macintosh computer (maverick). For now I do not manage to install version 4.6.5 on OS X Maverick. But this is another problem. Thank a lot for your answer that solve my difficulties. – DK06100 Aug 25 '14 at 11:16
  • I mentioned the version only for completeness, works fine also with 4.4.3. – Christoph Aug 25 '14 at 11:20