图表部分放大

图表部分放大

我怎样才能取出图表中放大的部分?

我有一个例子。在我的图表上,我需要缩放红色框。

该图表有代码:

\begin{tikzpicture}
\begin{axis}[xmin = 0, ymax = 75,title ={U=f(I)} ,xlabel = {$I$}, ylabel = {$U$},]
\addplot table {
    x     y
    225   45
    83   50
    38   54.3
    18   57.2
    8.8   59
    4.8   60.3
    1.95   68.4
    0.95   69.15
    0.5   69.4
};
\end{axis}
\end{tikzpicture}

谢谢

例子 我的聊天 拖拽图表

答案1

您可以用spy它来实现这一点。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots} 
\pgfplotsset{compat=1.17} 
\usetikzlibrary{spy} 
\begin{document}
\begin{tikzpicture}[spy using outlines={magnification=pi, size=3cm, connect spies}]
\begin{axis}[xmin = 0, ymax = 75,title ={U=f(I)} ,xlabel = {$I$}, ylabel = {$U$},]
\addplot table {
    x     y
    225   45
    83   50
    38   54.3
    18   57.2
    8.8   59
    4.8   60.3
    1.95   68.4
    0.95   69.15
    0.5   69.4
};
\path (0.5,69.4) coordinate (p);
\end{axis}
\spy [red] on (p)
in node [above left] at ([xshift=-1.1cm]current axis.west);
\end{tikzpicture}
\end{document}

在此处输入图片描述

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots} 
\pgfplotsset{compat=1.17} 
\begin{document}
\begin{tikzpicture}
\begin{axis}[name=large axis,xmin = 0, ymax = 75,title ={$U=f(I)$} ,xlabel = {$I$}, ylabel = {$U$},]
\addplot table {
    x     y
    225   45
    83   50
    38   54.3
    18   57.2
    8.8   59
    4.8   60.3
    1.95   68.4
    0.95   69.15
    0.5   69.4
};
\path (0.5,69.4) coordinate (ptl) (4.8,60.3) coordinate (pbr);
\end{axis}
\begin{axis}[anchor=north east,at={(large axis.north west)},xshift=-1.3cm,
    xmin = 0, ymax = 75,title ={$U=f(I)$} ,xlabel = {$I$}, ylabel = {$U$},
    width=5cm]
\addplot    table {
    x     y
    4.8   60.3
    1.95   68.4
    0.95   69.15
    0.5   69.4
};
\end{axis}
\draw[red] (ptl) rectangle (pbr) coordinate[midway](aux)
(aux-|ptl) -- (current axis.east);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容