4

I know my question is trivial. By the way, I can not show points given by their coordinates with a Bezier curve using Tikz.

    \documentclass{article}

    \usepackage{tikz}

    \begin{document}
    \begin{tikzpicture}
    \draw [<->,thick] (0,2) node (yaxis) [above] {$y$}
            |- (3,0) node (xaxis) [right] {$x$};
    %\draw [gray!50]  (0,0) -- (1,1) -- (3,1) -- (1,0)  -- (2,-1) -- cycle;
    \draw [red] plot [smooth] coordinates {(0,0) (1,1) (1.5, 1.5) (2,1.5) (2.5,2) (3,1) (1,0) (2,-1)};

    %\draw [gray!50, xshift=4cm]  (0,0) -- (1,1) -- (2,-2) -- (3,0);
    %\draw [cyan, xshift=4cm] plot [smooth, tension=2] coordinates { (0,0) (1,1) (2,-2) (3,0)};
    \end{tikzpicture}
\end{document}

which gives

enter image description here

I would like to give a draw like this

enter image description here

Many thanks for any help.

3
  • And, yes, you can definitely use tikz in beamer. :)
    – hpesoj626
    Feb 22 '13 at 14:58
  • Just add mark=* after the smooth option. Is that what you mean?
    – Jake
    Feb 22 '13 at 15:14
  • @cmhughes: Done
    – Jake
    Feb 22 '13 at 16:38
2

You can show plot the individual points by adding mark=* to the plot options, which will use a filled circle marker. There are many marker types, and they can be styled independently of the plot line (e.g. their size, colour, line thickness, etc.). Refer to the manual for more details.

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
    \draw [<->,thick] (0,2) node (yaxis) [above] {$y$}
            |- (3,0) node (xaxis) [right] {$x$};
    \draw [red] plot [smooth, mark=*] coordinates {(0,0) (1,1) (1.5, 1.5) (2,1.5) (2.5,2) (3,1) (1,0) (2,-1)};
    \end{tikzpicture}
\end{document}
1
  • @Averroès: Thanks for accepting! In the process, you also downvoted the answer by clicking the downward pointing triangle. I assume that was by accident? In that case, would you mind undoing the downvote?
    – Jake
    Feb 23 '13 at 16:42

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.