Different curve shapes when putting arrows

\draw [Bluey!160!,ultra thick, smooth,tension=0.7] plot coordinates {(-3,4)(-2,-3) (0,1)(2,-3)(3,4)};


When I draw this curve without putting arrows it looks like:

And after putting arrows

\draw [Bluey!160!,ultra thick, smooth,tension=0.7,<->] plot coordinates {(-3,4)(-2,-3) (0,1)(2,-3)(3,4)};


it looks like:

Can anyone tell me the reason?

This is the complete code

\begin{scope}[>={Latex[scale=1.2]}, thick]
\draw [dotted,thin] (-6,-6) grid (6,6);
\draw [<->] (-6.5,0)--(6.5,0) node [right] {\Large$$}; \foreach \x in {-5,...,-1,1,2,...,5}{ \draw (\x,-1mm)-- node [below=0.5mm] {\x} (\x,1mm);} \draw [<->] (0,6.5) node [above] {\Largey}--(0,-6.5); \foreach \y in {-5,...,-1,1,2,...,5}{ \draw (1mm,\y)-- node [left=0.5mm] {\y} (-1mm,\y);} \draw [blue,ultra thick,tension=1,<->, smooth] plot coordinates {(3,4)(2,-3)(0,1)(-2,-3)(-3,4)}; \end{scope}  • Welcome to TeX.SE. Can you add your complete MWE, please? – Sebastiano May 17 '17 at 8:05 • Apart from @Sebastiano's comment. I would recommend using a function (polynomial here I guess) and not curve segments. – Dr. Manuel Kuehner May 17 '17 at 8:26 • \begin{scope}[>={Latex[scale=1.2]}, thick] \draw [dotted,thin] (-6,-6) grid (6,6); \draw [<->] (-6.5,0)--(6.5,0) node [right] {\Large$$}; \foreach \x in {-5,...,-1,1,2,...,5}{ \draw (\x,-1mm)-- node [below=0.5mm] {$\x$} (\x,1mm);} \draw [<->] (0,6.5) node [above] {\Large$y$}--(0,-6.5); \foreach \y in {-5,...,-1,1,2,...,5}{ \draw (1mm,\y)-- node [left=0.5mm] {$\y$} (-1mm,\y);} \draw [blue,ultra thick,tension=1,<->, smooth] plot coordinates {(3,4)(2,-3)(0,1)(-2,-3)(-3,4)}; \end{scope} – sarah hussein May 17 '17 at 12:23
• Please edit the question and do not post code in a comment. Have a look at this gallery: pgfplots.sourceforge.net/gallery.html, It is a collection of the examples in the pgfplots manual. pgfplots is a package to draw diagrams: ctan.org/pkg/pgfplots – Dr. Manuel Kuehner May 17 '17 at 19:36
• The code that you posted is not complete. Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Troy May 21 '17 at 9:45

1 Answer

Because you are using both smooth and arrowheads, the arrowheads are causing the path to be shortened slightly such that the arrowhead touches the final point. This causes the smoothening algorithm to consider slightly different start and final points hence the difference. Or at least I think so. I didn't check it.

Instead use the proper tool: pgfplots

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}

\begin{tikzpicture}
\begin{axis}[axis lines=center,grid=both,ymin=-5,ymax=5,xmin=-5,xmax=5]
\addplot+[domain=-3:3, no marks,<->,thick,samples=51] {4/15*x^4 -31/15*x^2+ 1};
\end{axis}
\end{tikzpicture}
\end{document}