它是图表的一部分吗?
\begin{tikzpicture}\begin{axis}[
xtick=\empty, ytick=\empty,
minor tick num=0,
anchor=origin, % Align the origins
axis lines=middle,
ymax=8,xmax=8,xmin=-5,ymin=-5,
%axis equal,
axis lines=center, scale=1,
transform shape,
xlabel=$x$,ylabel=$y$]
\addplot[dashed,domain=-4:7] {x};
\addplot[domain=-1.5:1.5] {x^5-1};
\addplot[domain=-4:7,samples=100] {(x+1)^(1/5)};
\end{axis}
\end{tikzpicture}
答案1
正如 JPi 所说,问题在于带有分数指数的负数是一个问题。您可以通过确保底数为正来解决这个问题。这需要将函数分成两部分。写入 -abs(x+1)^(1/5) 可确保底数为正,然后在末尾加上负号以给出正确的值。另一个问题是两个图形不相连,因为函数在该点附近变化太快。所以我将它分成另一部分,并确保有很多点可以填补空白。该空白是函数在 -1.05 到 -1 上的绘图。
\documentclass{standalone}
\usepackage[dvipsnames]{xcolor}%
\usepackage{pgfplots}%
\pgfplotsset{compat=newest}%
\pgfmathdeclarefunction{f}{1}{%
\pgfmathparse{x^5-1}%
}
\pgfplotsset{compat=newest}%
\pgfmathdeclarefunction{g}{1}{%
\pgfmathparse{(x+1)^(1/5)}%
}
\pgfplotsset{compat=newest}%
\pgfmathdeclarefunction{h}{1}{%
\pgfmathparse{-abs(x+1)^(1/5)}%
}
\pgfplotsset{compat=newest}%
\pgfmathdeclarefunction{j}{1}{%
\pgfmathparse{x}%
}
\tikzset{Line Style1/.style={smooth,thick, samples=500}}
\tikzset{Line Style2/.style={smooth,thick, samples=1000}}
\tikzset{Line Style3/.style={smooth,thick, samples=1000}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
height= 1\textwidth,
width = 1\textwidth,
thick,
black,
scale=1.0,
axis lines=center,
domain=-3:3.0
line join=bevel,
xmin=-3,
xmax=3,
ymin=-3,
ymax=3,
xticklabels=\empty,
yticklabels=\empty,
major tick length=5pt,
major x tick style={black,very thick},
major y tick style={black,very thick}
]
\addplot[Line Style1, color=NavyBlue, domain=-1:3] (\x,{g(\x)});
\addplot[Line Style2, color=NavyBlue, domain=-3:-1.05] (\x,{h(\x)});
\addplot[Line Style3, color=NavyBlue, domain=-1.05:-1] (\x,{h(\x)});
\addplot[Line Style1, color=Peach, domain=-2:2] (\x,{f(\x)});
\addplot[dashed, color=Orchid, domain=-3:3] (\x,{j(\x)});
\end{axis}
\end{tikzpicture}
\end{document}