5

I want to draw graph of the function abs(\x^3)-3*abs(\x) with pgfplots. I tried

\documentclass[12pt]{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\pgfplotsset{compat=1.9}
\usepackage{fouriernc}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
declare function={Y(\x)=abs(\x^3)-3*abs(\x);},
axis line style = very thick,
    axis lines = center,
    xlabel=$x$,ylabel=$y$,
        domain=-2.2:2.2,
        ymin=-2.5,
        ymax=2.5,
        xmin=-2.5,
        xmax=2.5,
    samples=100,xtick distance=1,
ytick distance=2,unit vector ratio*=1 1 1,
    width=11cm,
    grid=major,
    grid style={gray!30}]
\addplot [black, ultra thick,name path =B] {Y(x)};
\addplot [black, mark=*,only marks,samples at={-2,-1,1,2}] {Y(x)};
\node at (axis cs:-0.25, -0.25) {$O$} ;
\addplot[color=black,dashed] coordinates {(-2,0)
        (-2,2)
        (2,2) (2,0)
         };
         \addplot[color=black,dashed] coordinates {(-1,0)
        (-1,-2) (1,-2) (1,0)
        };
\end{axis}
\end{tikzpicture}
\end{document} 

The graph is not continuous at (0,0).

enter image description here

enter image description here

0 Answers0