TikZ 问题:绘制函数 2000*1.01^x 的图形

TikZ 问题:绘制函数 2000*1.01^x 的图形

我正在使用 TikZ 绘制一些图形,但是无法使用 LateX 绘制2000*1.01^x

以下是代码:

\begin{tikzpicture}[xscale=1, yscale=0.1]
\draw[very thick,red] (0,2000) -- (0,2150) node[anchor=south] { $y$};
\draw[xstep=1, ystep=5 , very thin, color=gray] (0,2000) grid (5,2150);
\draw[very thick, black, domain=0:5,samples=1000,variable=\x] plot ( \x , {2000*(1.01)^(\x)}) ;
\end{tikzpicture}

出了什么问题?

答案1

直线是正常的,因为当你取 1.01 的幂时,它不会很快偏离 1。你正在cm使用 Tikz 进行操作,使用pgfplots它。它不需要特别注意大数字。这是一条更快的曲线

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}% Package Version
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both]
\addplot{2000*(1.3)^x};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

如果pgfplots较慢,您可以gnuplot与一起使用pgfplots。我采用了 percusse 的示例并添加了,gnuplot只是为了说明它是多么简单。此外,我还将 2000 更改为 10000000 并使用了domain=1:10

使用--shell-escape--enable-write18( pdflatex --shell-escape filename) 编译它,您应该已经gnuplot安装并且它应该在系统路径中。

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}% Package Version
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both]
\addplot+[domain=0:10] gnuplot {10000000*(1.3)^x};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

推荐使用 PSTricks 的解决方案,只是为了好玩。

\documentclass[pstricks,border=25pt]{standalone}
\usepackage{pst-node,pst-plot}

\begin{document}
\psset{yunit=\dimexpr1cm/2000\relax}
\begin{pspicture}[showgrid=false](-6,0)(6,10000)
\psplot[plotpoints=25,algebraic,linecolor=blue]{-5}{5}{2000*1.3^x}
\psaxes[Dy=1000,linecolor=gray]{->}(0,0)(-6,0)(6,10000)[$x$,0][$y$,90]
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容