我已经在这个网站上获取了代码(Manuel Kuehner 编辑/猜测:使用 TikZ/pgf 绘制多个函数)
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot (\x, \x) node[right] {$f(x) =x$};
\draw[color=blue] plot (\x, { sin(\x r) }) node[right] {$f(x) = \sin x$};
\draw[color=orange] plot (\x, { 0.05*exp(\x) })
node[right] {$f(x) = \frac{1}{20} \mathrm e^{x}$};
\end{tikzpicture}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot (\x, {-\x / 3 + 1/5}) node[right] {$f(x)$};
\draw[color=blue] plot
(\x, { 1/2 * \x + 1/2 - 1/2 * sqrt(5 * \x^2 + 2*\x + 1)})
node[right] {$g(x)$};
\end{tikzpicture}
\end{document}
我想使用放大镜仅使用坐标来缩放图形中的通用点。也就是说,固定通用坐标,我想知道是否有通用命令可以查看图形中的特定点。这就是我想要得到的结果。
谢谢。
答案1
我猜你正在寻找所谓spy
的功能tikz
(不是pgfplots
,但你可以在内使用它pgfplots
)。在pgfplots
手册中,你可以找到一个例子:
以下是相应章节的截图pgf/tikz
:
% https://tex.stackexchange.com/questions/200354
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{spy} % <-- added
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[
domain=0:4,
spy using outlines={circle, magnification=4, size=2cm, connect spies}, % <-- added (pgf manual example)
]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot (\x, \x) node[right] {$f(x) =x$};
\draw[color=blue] plot (\x, { sin(\x r) }) node[right] {$f(x) = \sin x$};
\draw[color=orange] plot (\x, { 0.05*exp(\x) })
node[right] {$f(x) = \frac{1}{20} \mathrm e^{x}$};
\spy [red] on (1.6,0.3) in node [left] at (3.5,-1.25); % <-- added (pgf manual example)
\end{tikzpicture}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot (\x, {-\x / 3 + 1/5}) node[right] {$f(x)$};
\draw[color=blue] plot
(\x, { 1/2 * \x + 1/2 - 1/2 * sqrt(5 * \x^2 + 2*\x + 1)})
node[right] {$g(x)$};
\end{tikzpicture}
\end{document}