我有这段代码可以在乳胶中绘制图形,但我不确定这有什么问题。
\begin{tikzpicture}
\begin{axis}[
axis lines = center, % middle
xlabel = $x$, ylabel = {$y$},
xmin = {-10},xmax = {12},
ymin = {-5},ymax = {7},
% restrict y to domain = -10:10,
xtick = \empty, ytick = \empty, % to add the label to the axis
extra x ticks = {-1,8}, % To just add specific points
% extra y ticks = {1}
% xtick={-10,...,10},
% ytick={-8,...,12}
]
\addplot[domain = -5:10, samples = 200, color = blue] {1/x^(1/3)} node[above left] {$f(x)=\dfrac{1}{\sqrt[3]{x}}$};
% \addplot[domain = -10:2, samples = 100, color = blue] {1/x^(1/3)}
\end{axis}
\end{tikzpicture}
我无法获得第三象限的曲线。
答案1
\documentclass[fleqn]{article}
\usepackage{amsmath}
\DeclareMathOperator{\sign}{sign}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
Note that
\[ x^\alpha=\exp(\alpha\,\ln x)\;,\]
so negative values are worrisome for fractional $\alpha$.
However, you can plot (cf.\ Figure~\ref{fig:plot})
\[ \sign x \cdot |x|^\alpha\;.\]
\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}[
axis lines = center, % middle
xlabel = $x$, ylabel = {$y$},
xmin = {-10},xmax = {12},
ymin = {-5},ymax = {7},
% restrict y to domain = -10:10,
xtick = \empty, ytick = \empty, % to add the label to the axis
extra x ticks = {-1,8}, % To just add specific points
% extra y ticks = {1}
% xtick={-10,...,10},
% ytick={-8,...,12}
]
\addplot[domain = -5:10, samples = 200, color = blue] {sign(x)/abs(x)^(1/3)}
node[above left] {$f(x)=\dfrac{\sign x}{\sqrt[3]{|x|}}$};
% \addplot[domain = -10:2, samples = 100, color = blue] {1/x^(1/3)}
\end{axis}
\end{tikzpicture}
\caption{Plot of $f(x)=\dfrac{\sign x}{\sqrt[3]{|x|}}$.}
\label{fig:plot}
\end{figure}
\end{document}