I have the following code

    \begin{scope}[xshift=4cm, scale=1]

\draw[->] (-0.2,0) -- (10.5,0) node[right] {$x$}; 
\draw[->] (0,-0.5) -- (0,6.5) node[above] {$f(x)$}; 
\draw[color=red] plot (\x,{0.0018 *pow(\x,3)-0.0728* pow(\x,2)+0.8947
*\x+1.0173}) ;
 \draw[color=blue,domain=8:10] plot (\x,{-0.0001109 *(\x)^5+0.0041994*(\x)^4-

0.060293* (\x)^3+0.43576 *(\x)^2-1.80134* (\x)+5.3364}) ;

\end {scope}

It gives me the following picture:

enter image description here

It just doesn't make sense, it it supposed to look like that:

enter image description here

Can somebody help me?

migrated from stackoverflow.com Nov 23 '17 at 16:09

This question came from our site for professional and enthusiast programmers.

  • can you add the matlab version of the code? – percusse Nov 23 '17 at 16:16

You should use PGFPlots instead of drawing the coordinate system on your own.



    \begin{axis}[domain=0:10, axis y line = middle, axis x line = middle]
    \addplot[red] {0.0018 * pow(x,3)-0.0728* pow(x,2)+0.8947
    \addplot[blue, domain=8:10] {-0.0001109 *(x)^5+0.0041994*(x)^4-0.060293* (x)^3+0.43576 *(x)^2-1.80134* (x)+5.3364};


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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