I'm trying to draw the graph of a curve in three dimensions. For some reason, tikz/pgfplots is automatically closing the curve. I can't figure out how to stop it from doing this. Here is an example:

    \addplot3 [
      domain=-1.5:1.5] ({t},{0},{20-t^2});

What it produces for me is the following:

enter image description here

For some reason, it has connected the start and end points of the curve.

  • For reference, this is described in the pgfplots manual, in the section about \addplot3. In the manual for version 1.18.1, it's section 4.6.2 The \addplot3 Command: Three Dimensional Coordinate Input, on page 125. Quote: "The “auto-completion” depends on how you provide your data. • If you use \addplot3 expression, mesh/rows and mesh/cols are computed from the values samples and samples y. By default, \addplot3 expression always samples a mesh. If you want it to sample a line, set samples y=1 (or, equivalently, y domain=0:0)." Jun 28 at 15:29

You need to tell PGFPlots to only draw the curve once with samples y=1:

    \addplot3 [variable=t, domain=-1.5:1.5, samples y=1] ({t},{0},{20-t^2});


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.