gpt4 book ai didi

latex - 添加情节 : set default domain

转载 作者:行者123 更新时间:2023-12-04 15:55:38 25 4
gpt4 key购买 nike

pgfplots 中,绘制函数时,-5:5 中的默认域。我想将其默认设置为 xmin:xmax。有没有办法做到这一点?换句话说,我希望能够写

\addplot {x^2};

代替

\addplot[domain=xmin:xmax] {x^2};

更具体地说,这是我寻找的(但不起作用)的 MWE:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{domain = min:max}
\begin{document}

\centering
\begin{tikzpicture}
\begin{axis}[xmin=-10, xmax=10, xlabel = $x$, ylabel = {$f(x) = x^2$}]
\addplot{x^2};
\end{axis}
\end{tikzpicture}
\end{document}

最佳答案

\documentclass{article}
\usepackage{pgfplots}

%What you really need!
\newcommand\Min{-10}
\newcommand\Max{10}
\pgfplotsset{domain = \Min : \Max}

\begin{document}
\centering
\begin{tikzpicture}%x^2
\begin{axis}[xlabel = $x$, ylabel = {$f(x) = x^2$}]
\addplot{x^2};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}%-(x^2)
\begin{axis}[xlabel = $x$, ylabel = {$f(x) = -(x^2)$}]
\addplot{-x^2};
\end{axis}
\end{tikzpicture}
\end{document}

Output

关于latex - 添加情节 : set default domain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51812706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com