Are these functions correctly drawn (two planes and a line)?

I would like to plot 2x+2y-z+9=0, 2x+2y-z-9=0 and the line X=(-1,0,4)+λ(2,2,-1), that is, passed through the points (-1,0,4) and (1,2,3), but I think that I made a mistake in the formulas of the planes, because I think there is not the plot that I see with GeoGebra:

The red axis is x-axis, and the green is y-axis.

How can we make a graph similar to the second image?

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\pgfplotsset{soldot/.style={color=black,only marks,mark=*}}
\pgfplotsset{holdot/.style={color=red,fill=white,very thick,only marks,mark=*}}

\begin{document}

\begin{tikzpicture}[declare function={f1(\x,\y)=2*\x+2*\y+9;f2(\x,\y)=2*\x+2*\y-9;}]
\begin{axis}[
axis on top,
legend pos=outer north east,
axis lines = center,
xticklabel style = {font=\tiny},
yticklabel style = {font=\tiny},
zticklabel style = {font=\tiny},
xlabel = $x$,
ylabel = $y$,
zlabel = $z$,
legend style={cells={align=left}},
legend cell align={left},
view={-160}{25},
clip=false
]
\draw[red,very thick] (-1,0,4) -- (1,2,3);
\addplot3[soldot] coordinates {(0,-9/2,0)} node[above right] {$$(0,-\frac92,0)$$};
\end{axis}
\end{tikzpicture}

\end{document}


Thanks!

EDIT. Sebastiano's good advice shows that both z-axis are not scaled at same values. So from this MWE I delete clip=false and added zmin=-1,zmax=5 but now the graph seems "cut":

I would like to preserve the square (rhombus with view={-160}{25}) as GeoGebra do.

• Hi, do you like Geogebra :-)? I vote, at least for me always positive, for a question with a job that takes so long. – Sebastiano Nov 8 '18 at 21:07
• I always vote positive for a question where the operator has taken a long time: +1 for you. I use the translator Deepl translator :-(. – Sebastiano Nov 8 '18 at 21:11
• You can see on the z-axis that the two images are not on the same scale. The axes should be scaled identically to be able to compare. Furthermore it is not very clear, where the planes are cut off. There is kind of an invisible container around the planes that defines where the plane is cut off. But the shape of the container is not well defined... – Stefan Schroeder Nov 8 '18 at 21:12
• @Sebastiano oh, thank you! I think this is a very basic question :(. I appreciate you and your awesome answers. – manooooh Nov 8 '18 at 21:14
• For some reason your code behaves strangely when I play with it. However, if you really want to go this way (rather than using asymptote or tikz-3dplot), I'd at least add something like unit vector ratio=1 1 1. – user121799 Nov 8 '18 at 21:24

This is now more like an answer.

1. I use unit vector ratio=1 1 1 to prevent the axes from being rescaled differently.
2. I clip the picture "by hand".
3. It is (again) a bit like a math question. I use a different parametrization for the plane. The basic observation is that, for a given z, x+y is constant. This suggests to switch to new variable u=(x+y)/2 and v=(x-y)/2, and renaming those to x and y. In the new coordinates, the domain for v, which got renamed y, controls the "width" of the plane, i.e. how far it extends for a given z. And the domain of u, i.e. the new x is taken to be such that z runs from -5 to 5, if you increase this domain, the planes will get higher.
4. In this new parametrization, it is fairly easy to split the planes in two parts, one with negative z and one with positive z. So I draw first the negative ones, then an x-y plane and finally the positive ones. The red line is drawn according to the same logic.

So the code becomes

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}

\begin{tikzpicture}
\begin{axis}[width=16cm,
set layers,colormap/viridis,
legend pos=outer north east,
axis lines = center,
xticklabel style = {font=\tiny},
yticklabel style = {font=\tiny},
zticklabel style = {font=\tiny},
xlabel = $x$,
ylabel = $y$,
zlabel = $z$,ztick={2,4},%zticklabels={},
legend style={cells={align=left}},
legend cell align={left},
view={-160}{25},
unit vector ratio=1 1 1,xmin=-6,xmax=6,ymin=-6,ymax=6,zmin=-5,zmax=5,
clip=false
]

\clip ([xshift=1.5cm,yshift=1.5cm]current axis.south west) rectangle
([xshift=-1.5cm,yshift=-1.5cm]current axis.north east);
domain=2:4.5,domain y=-8:8] ({(x+y)/2},{(x-y)/2},{2*x-9});
domain=-7:-4.5,domain y=-8:8] ({(x+y)/2},{(x-y)/2},{2*x+9});
domain=-6:6,domain y=-6:6,opacity=0.5] {0};
\draw[red,very thick]  (-5/3, -2/3, 13/3) -- (-4-5/3,-4-2/3,2+13/3);
domain=-4.5:-2,domain y=-8:8] ({(x+y)/2},{(x-y)/2},{2*x+9});
\draw[red,very thick] (-5/3, -2/3, 13/3) -- (7/3, 10/3, 7/3);