# How to plot equation (not function) with TikZ [duplicate]

I want to plot an equation, not a function, with TikZ. Is there any general way to realize it without calculation?

For example to plot the equation: 2x²-2xy+2y²=1 as follows

• Place a \node, e.g. at (1.5, 0.4), and enter text in math mode, like \node at (1.5, 0.4) {$2 x^2 ...$};  . That should do the job. Commented Jun 12, 2022 at 10:52
• The pedestrian way: find the corresponding function, e.g. in wolframalpha.com 2x^2 - 2xy + 2y^2 = 1; solve (y): y = 1/2 (x - sqrt(2 - 3 x^2)), y = 1/2 (x + sqrt(2 - 3 x^2)) Commented Jun 12, 2022 at 11:09
• ...or you can use the plotting of implicit function through gnuplot: tex.stackexchange.com/questions/18359/… Commented Jun 12, 2022 at 11:18

This (standing on the shoulder of giants) works. There is a warning Missing character: There is no    in font nullfont! which I do not like at all, but I am not sure where it comes from.

You must compile with -shell-escape and have a recent gnuplot installed and reachable in your standard PATH.

\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
grid,
xmin = -1, xmax=3,
ymin=-1, ymax=1,
]
raw gnuplot,
thick,
empty line = jump %
] gnuplot {
set xrange[-1:3];
set contour base;
set cntrparam levels discrete 0.0;
unset surface;
set view map;
set isosamples 500;
splot 2*x*x-2*x*y+2*y*y-1;
};
\path (1,0.5) node[right, fill=white]{$2x^2-2xy+2y^2=1$};
\end{axis}
\end{tikzpicture}
\end{document}
`

• Thank you so much!
– Ben
Commented Jun 12, 2022 at 20:11