1

Checking pgfplot for the addplot3-command was easy! I've found this very nice possibility to plot a plane:

\begin{tikzpicture}
\begin{axis}
\addplot3[
    surf,
    mesh,
]
{x+y+1};
\end{axis}
\end{tikzpicture}

enter image description here

But to emphasize the meaning of the gradient vector I would like to add a vector (1,1,0). Furthermore I need labels for my coordinate system. And how can I add points, e.g. "the origin", to indicate that the functions returns 1 for x=y=0? Thanks for advice.

Here is a specification of the underlying problem: adding a circle or vector refers to the invisible 2d-coordinate system but not to the one plotted.

\begin{tikzpicture}
\begin{axis}
\addplot3[
    surf,
        mesh,
]
{x+y+1};
\end{axis}
\draw[->] (1,1,0) -- (2,2,0);
\draw (0,0,1) circle (10pt);
\end{tikzpicture}

enter image description here

\begin{center}
\begin{tikzpicture}
\begin{axis}[
    xlabel={$x$},
    ylabel={$y$}]
\addplot3[
    surf, mesh
        ]
{x+y+1};
\draw[->, ultra thick] (0,0,0) -- (1,1,0);
\fill[red] (0,0,0) circle (2pt);
\draw[->] (1,1,0) -- (2,2,0);
\end{axis}
\end{tikzpicture}
\end{center}

enter image description here

Of course I just mixed up the environment of the addplot3 with the axis environment and possible other subsequent elements. Everythings fine now.

6
  • Just like with any other axis, you can use the regular TikZ drawing commands to add lines, nodes, etc. to the plot, with the usual 3D coordinate, e.g. \draw[->] (0,0,0) -- (1,1,0)
    – darthbith
    May 19, 2016 at 15:50
  • Let me specify my problem. The coordinate system drawn is different from what my code works with.
    – Mac
    May 19, 2016 at 16:11
  • 3
    You need put the \draw commands inside the axis environment, and you need to set \pgfplotsset{compat=1.12} or use (axis cs:0,0,0) instead of (0,0,0).
    – Jake
    May 19, 2016 at 16:38
  • @Mac I agree with Jake (and I should have been more explicit). You can also use \pgfplotsset{compat=1.13} in the preamble (and I would recommend to use 1.13 which is the most recent version, unless you have a compelling reason to use an older version)
    – darthbith
    May 19, 2016 at 16:57
  • 4
    I'm voting to close this question because it is solved in the comments. Feb 25, 2017 at 14:13

0

Browse other questions tagged or ask your own question.