TikZ - 初等函数图

TikZ - 初等函数图

我想问一下您是否有类似用 TikZ 制作的一页上的基本函数图。我写论文,想从您的代码和设计中获得灵感。这将非常有帮助。

谢谢你!

答案1

您可以使用强大的pgfplots包;文档中充满了启发性的示例。下面仅展示一小部分三角函数、指数函数和有理函数的图形。在示例中,我展示了轴、刻度、标签、标题、描述、网格的不同样式:

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{pgfplots}

\pgfplotsset{compat=1.8}
\tikzset{
every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt},
small dot/.style={fill=black,circle,inner sep=1pt}
}

\pagestyle{empty}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
axis lines=middle,
xtick={-6.28318, -3.15159265, ..., 6.28318},
xticklabels={$-2\pi$,$-\pi$,0,$\pi$,$2\pi$},
grid=major,
legend style={legend pos=outer north east}
]
\addplot+[no marks,domain=-2*pi:2*pi, samples=100]{cos(deg(x))};
\addlegendentry{$f(x)=\cos(x)$}
\addplot+[no marks,domain=-2*pi:2*pi, samples=100]{sin(deg(x))};
\addlegendentry{$g(x)=\sin(x)$}
\end{axis}
\end{tikzpicture}\par\bigskip

\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
axis lines=middle,
legend style={legend pos=outer north east},
extra x ticks={2},
extra x tick style={grid=major}
]
\addplot+[no marks,domain=-8:12,unbounded coords=jump,samples=101]{(x-2)^(-1)};
\node[small dot,pin=60:{$f(x)=(x-2)^{-1}$}] at (axis cs:3,1) {};
\end{axis}
\end{tikzpicture}\par\bigskip

\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=3,
ymin=0,
ymax=15,
samples=100,
extra y ticks={2.71828},
extra y tick labels={$e$},
title={Graph of $h(x)=e^{x}$}
]
\addplot[no marks,cyan] {exp(x)};
\draw[dashed] (axis cs:1,0) -- (axis cs:1,2.71828); 
\draw[dashed] (axis cs:0,2.71828) -- (axis cs:1,2.71828);
\node[small dot,fill=red] at (axis cs:1,2.71828) {};
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容