在 tikz 方案中添加“缩放”效果

在 tikz 方案中添加“缩放”效果

我想问一下是否可以使用 tikz 添加一种“缩放”效果?更准确地说:我试图重现这样的图形:

在此处输入图片描述

感谢另一位用户:我可以根据需要分别绘制两个图形。但我想在我的文本中实现这种缩放效果,以便更易于理解。

\documentclass{article}

\usepackage{caption}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{accents} 
%%%%%%%%SECTIONS/AGENCEMENT%%%
\usepackage{enumitem}
\usepackage{pgf, tikz, adjustbox}
\usetikzlibrary{patterns, matrix, positioning}
\usetikzlibrary{arrows.meta,
                patterns.meta
                }  


\begin{document}
%%%%%%%%%%%%%FIGURE 4%%%%%%%%%%%%%%%
\begin{figure}[h]
\centering
\begin{tikzpicture}[
         > = Straight Barb,
dot/.style = {circle, fill, inner sep=2.0pt, node contents={}},
every label/.append style = {label distance =2pt, inner sep=1pt, fill=white},
   samples = 101,
    domain = 0:10
                        ]
% axis
\draw[-stealth] (-2.5, 0) -- (13,  0) node[right] {$\underline{e}_x$}; % x-axis
\draw[-stealth] (0, -0.5) -- ( 0,4.3) node[above] {$\underline{e}_z$}; % y-axis
\foreach \i in {-2,-1,0, ...,12} 
\draw   (\i, 1mm) -- ++ (0,-2mm);
% function
\draw[very thick, blue]    
    plot    ({\x}, {(exp(1-(\x^2)/16)) + 1/2}) -- (10,1/2);
\path[pattern={Lines[angle=45,distance={3pt},
               line width=0.2pt]},
               pattern color=blue]
    plot    ({\x}, {(exp(1-(\x^2)/16)) + 1/2}) |- (0,0) ;
\node[right] at (2,1.2) {$V$};

% domain
\path   (0,0) node[red,dot,label=below left:$0$] (0,3.2) node[dot,label=left:$h_0$] (10,0) node[red,dot,label=below:$L$];
\end{tikzpicture}
\caption{This is it}
\end{figure}



\begin{figure}[h]
\centering
\begin{tikzpicture}[
         > = Straight Barb,
dot/.style = {circle, fill, inner sep=2.0pt, node contents={}},
every label/.append style = {label distance =2pt, inner sep=1pt, fill=white},
   samples = 101,
    domain = 0:10
                        ]
% axis
\draw[-stealth] (-2.5, 0) -- (13,  0) node[right] {$\underline{e}_x$}; % x-axis
\draw[-stealth] (0, -0.5) -- ( 0,4.3) node[above] {$\underline{e}_z$}; % y-axis
\foreach \i in {-2,-1,0, ...,12} 
\draw   (\i, 1mm) -- ++ (0,-2mm);
% function
\draw[very thick, blue]    
    plot    ({\x}, {2*exp(-\x/5) + 1/2}) -- (10,0.75);
\path[pattern={Lines[angle=45,distance={3pt},
               line width=0.2pt]},
               pattern color=blue]
    plot    ({\x}, {2*exp(-\x/5)+ 1/2}) |- (0,0) ;
\node[right] at (2,1.2) {$V$};

% domain
\path   (0,0) node[red,dot,label=below left:$L$]  (10,0) node[red,dot,label=below:$\infty$];
\end{tikzpicture}
\end{figure}



\end{document}

答案1

我会使用 PGFPlots 来绘制轴,而不是手动绘制。如果缩放是真正的缩放,则可以使用库自动绘制spy。但在这种情况下,我猜这不是“缩放”。

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{patterns.meta, arrows.meta}  
\begin{document}
\begin{tikzpicture}[
dot/.style = {circle, fill, inner sep=2.0pt, node contents={}},
every label/.append style = {label distance =2pt, inner sep=1pt, fill=white},
samples = 101,
domain = 0:10
]
\draw[-stealth] (-2.5, 0) -- (13,  0) node[right] {$\underline{e}_x$}; % x-axis
\draw[-stealth] (0, -0.5) -- ( 0,4.3) node[above] {$\underline{e}_z$}; % y-axis
\foreach \i in {-2,-1,0, ...,12} 
\draw   (\i, 1mm) -- ++ (0,-2mm);
\draw[very thick, blue]    
plot    ({\x}, {(exp(1-(\x^2)/16)) + 1/2}) -- (10,1/2);
\path[pattern={Lines[angle=45,distance={3pt},
line width=0.2pt]},
pattern color=blue]
plot    ({\x}, {(exp(1-(\x^2)/16)) + 1/2}) |- (0,0) ;
\node[right] at (2,1.2) {$V$};
\path   (0,0) node[red,dot,label=below left:$0$] (0,3.2) node[dot,label=left:$h_0$] (10,0) node[red,dot,label=below:$L$];
\node[draw, thick, circle, minimum size=1cm] (a) at (10,0.7) {};
\draw[thick, -{Triangle[open, scale=2]}] (a) to[bend left] (12,2);
\begin{scope}[shift={(14,2)}, scale=0.4]
\draw[-stealth] (-2.5, 0) -- (13,  0) node[right] {$\underline{e}_x$}; % x-axis
\draw[-stealth] (0, -0.5) -- ( 0,4.3) node[above] {$\underline{e}_z$}; % y-axis
\foreach \i in {-2,-1,0, ...,12} 
\draw   (\i, 1mm) -- ++ (0,-2mm);
\draw[very thick, blue]    
plot    ({\x}, {2*exp(-\x/5) + 1/2}) -- (10,0.75);
\path[pattern={Lines[angle=45,distance={3pt},
line width=0.2pt]},
pattern color=blue]
plot    ({\x}, {2*exp(-\x/5)+ 1/2}) |- (0,0) ;
\node[right] at (2,1.2) {$V$};
\path   (0,0) node[red,dot,label=below left:$L$]  (10,0) node[red,dot,label=below:$\infty$];
\end{scope}
\end{tikzpicture}
\end{document}

两张图

相关内容