仅剪切 pgfplots/tikz 中的图形底部?

仅剪切 pgfplots/tikz 中的图形底部?

是否可以只剪切图形的底部?我有一个图形,其区域上方有一个节点;当启用整个图形的剪切时,该节点将被切掉。但是,不进行剪切意味着函数会略微延伸到底部 x 轴。

在你的序言中写明这些:

\usepackage{graphics}
\usepackage{tikz}
\usetikzlibrary{positioning, calc, plotmarks, patterns, arrows}
\tikzset{>=stealth}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

剪掉 放大

\begin{tikzpicture}[scale=1, transform shape]  %horizontal projection
%variable definitions
\def\g{-9.8} %gravity
\def\v{10} %velocity
\def\ang{51} %angle
\def\s{0.125}
\pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}}
\pgfmathsetmacro{\a}{{(-1*(2/\g)*\v*sin(\ang))*.9}}

\begin{axis}[
width=.7\linewidth, %set bigger width
height=4in,
xmin={{\v*cos(\ang)*\c}},xmax=10, %{\v*cos(\ang)*\a+\s*\v*cos(\ang)}
ymin=0,ymax={\v*\c*sin(\ang)+0.5*\g*(\c^2)},
xlabel=$X$,
ylabel=$y$,
axis x line = bottom,
axis y line = left,
y axis line style={<-},
x axis line style={<->},
ticks = none,clip=false,
]

\tikzset{every mark/.append style={fill=white}}

%flight path
\addplot[
dashed,
domain={\v*cos(\ang)*\c}:10,
samples=100,]
{{\g*(x^2)/(2*\v^2*cos(\ang)^2)+x*tan(\ang)}};

%vector at end
\pgfmathsetmacro{\a}{{(-1*(2/\g)*\v*sin(\ang))*.9}}
\coordinate (E) at (axis cs:{\v*cos(\ang)*\a},{\v*\a*sin(\ang)+0.5*\g*(\a^2)}){};
\coordinate (F) at (axis cs:{\v*cos(\ang)*\a+\s*\v*cos(\ang))}, {\v*\a*sin(\ang)+0.5*\g*\a^2+\s*(\v*sin(\ang)+\g*\a)});
\draw[very thick,->](E)--(F)
node[midway,sloped,above]{$\vec{V}$};
\draw[densely dashed,very thick,->](E)--(F |- E)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](E)--(F-| E)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(E)};

%vector at start
\pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}}
\coordinate (L) at (axis cs:{\v*cos(\ang)*\c},{\v*\c*sin(\ang)+0.5*\g*(\c^2)});
\coordinate (M) at (axis cs:{\v*cos(\ang)*\c+\s*\v*cos(\ang))},{\v*\c*sin(\ang)+0.5*\g*\c^2+\s*(\v*sin(\ang)+\g*\c)});
\draw[very thick,->](L)--(M)
node[midway,sloped,above]{$\vec{V}$};

\path plot[mark=*] coordinates {(L)};

%vector 1/2 down
\pgfmathsetmacro{\d}{{(-1*(2/\g)*\v*sin(\ang))*0.6}}
\coordinate (P) at (axis cs:{\v*cos(\ang)*\d},{\v*\d*sin(\ang)+0.5*\g*(\d^2)});
\coordinate (Q) at (axis cs:{(\v*cos(\ang)*\d+\s*\v*cos(\ang))},{\v*\d*sin(\ang)+0.5*\g*\d^2+\s*(\v*sin(\ang)+\g*\d)});
\draw[very thick,->](P)--(Q)
%node[midway,sloped,above]{$\vec{V}$}
;
\draw[densely dashed,very thick,->](P)--(Q|-P)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](P)--(Q-|P)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(P)};

%vector 3/4 down
\pgfmathsetmacro{\f}{{(-1*(2/\g)*\v*sin(\ang))*0.7}}
\coordinate (R) at (axis cs:{\v*cos(\ang)*\f},{\v*\f*sin(\ang)+0.5*\g*(\f^2)});
\coordinate (S) at (axis cs:{(\v*cos(\ang)*\f+\s*\v*cos(\ang))},{\v*\f*sin(\ang)+0.5*\g*\f^2+\s*(\v*sin(\ang)+\g*\f)});
\draw[very thick,->](R)--(S)
node[midway,above,sloped]{$\vec{V}$};
\draw[densely dashed,very thick,->](R)--(S|-R)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](R)--(S-|R)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(R)};

%vector 1/4 down
\pgfmathsetmacro{\e}{{(-1*(2/\g)*\v*sin(\ang))*0.8}}
\coordinate (T) at (axis cs:{\v*cos(\ang)*\e},{\v*\e*sin(\ang)+0.5*\g*(\e^2)});
\coordinate (U) at (axis cs:{(\v*cos(\ang)*\e+\s*\v*cos(\ang))},{\v*\e*sin(\ang)+0.5*\g*\e^2+\s*(\v*sin(\ang)+\g*\e)});
\draw[very thick,->](T)--(U)
node[midway,sloped,above]{$\vec{V}$};
\draw[densely dashed,very thick,->](T)--(U|-T)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](T)--(U-|T)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(T)};

%free fall comparison plots
\pgfmathsetmacro{\z}{{(\v*cos(\ang)*\c+\v*cos(\ang)*\c+\s*\v*cos(\ang))*.5}}

\draw[very thick,->] (axis cs:\z,{\v*\e*sin(\ang)+0.5*\g*(\e^2)}) -- (axis cs:\z,{\v*\e*sin(\ang)+0.5*\g*\e^2+\s*(\v*sin(\ang)+\g*\e)});
\draw[very thick,->] (axis cs:\z,{\v*\f*sin(\ang)+0.5*\g*(\f^2)}) -- (axis cs:\z,{\v*\f*sin(\ang)+0.5*\g*\f^2+\s*(\v*sin(\ang)+\g*\f)});
\draw[very thick,->] (axis cs:\z,{\v*\d*sin(\ang)+0.5*\g*(\d^2)}) -- (axis cs:\z,{\v*\d*sin(\ang)+0.5*\g*\d^2+\s*(\v*sin(\ang)+\g*\d)});
\draw[very thick,->] (axis cs:\z,{\v*\a*sin(\ang)+0.5*\g*(\a^2)}) -- (axis cs:\z,{\v*\a*sin(\ang)+0.5*\g*\a^2+\s*(\v*sin(\ang)+\g*\a)})
node[midway,right]{Vertical fall}
;
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\e*sin(\ang)+0.5*\g*(\e^2)})};
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\f*sin(\ang)+0.5*\g*(\f^2)})};
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\d*sin(\ang)+0.5*\g*(\d^2)})};
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\a*sin(\ang)+0.5*\g*(\a^2)})};

\end{axis}
\end{tikzpicture} 

开启剪辑功能:

剪辑

\begin{tikzpicture}[scale=1, transform shape]  %horizontal projection
%variable definitions
\def\g{-9.8} %gravity
\def\v{10} %velocity
\def\ang{51} %angle
\def\s{0.125}
\pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}}
\pgfmathsetmacro{\a}{{(-1*(2/\g)*\v*sin(\ang))*.9}}

\begin{axis}[
width=.7\linewidth, %set bigger width
height=4in,
xmin={{\v*cos(\ang)*\c}},xmax=10, %{\v*cos(\ang)*\a+\s*\v*cos(\ang)}
ymin=0,ymax={\v*\c*sin(\ang)+0.5*\g*(\c^2)},
xlabel=$X$,
ylabel=$y$,
axis x line = bottom,
axis y line = left,
y axis line style={<-},
x axis line style={<->},
ticks = none,clip=false,
]

\tikzset{every mark/.append style={fill=white}}

%flight path
\addplot[
dashed,
domain={\v*cos(\ang)*\c}:10,
samples=100,]
{{\g*(x^2)/(2*\v^2*cos(\ang)^2)+x*tan(\ang)}};

%vector at end
\pgfmathsetmacro{\a}{{(-1*(2/\g)*\v*sin(\ang))*.9}}
\coordinate (E) at (axis cs:{\v*cos(\ang)*\a},{\v*\a*sin(\ang)+0.5*\g*(\a^2)}){};
\coordinate (F) at (axis cs:{\v*cos(\ang)*\a+\s*\v*cos(\ang))}, {\v*\a*sin(\ang)+0.5*\g*\a^2+\s*(\v*sin(\ang)+\g*\a)});
\draw[very thick,->](E)--(F)
node[midway,sloped,above]{$\vec{V}$};
\draw[densely dashed,very thick,->](E)--(F |- E)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](E)--(F-| E)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(E)};

%vector at start
\pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}}
\coordinate (L) at (axis cs:{\v*cos(\ang)*\c},{\v*\c*sin(\ang)+0.5*\g*(\c^2)});
\coordinate (M) at (axis cs:{\v*cos(\ang)*\c+\s*\v*cos(\ang))},{\v*\c*sin(\ang)+0.5*\g*\c^2+\s*(\v*sin(\ang)+\g*\c)});
\draw[very thick,->](L)--(M)
node[midway,sloped,above]{$\vec{V}$};

\path plot[mark=*] coordinates {(L)};

%vector 1/2 down
\pgfmathsetmacro{\d}{{(-1*(2/\g)*\v*sin(\ang))*0.6}}
\coordinate (P) at (axis cs:{\v*cos(\ang)*\d},{\v*\d*sin(\ang)+0.5*\g*(\d^2)});
\coordinate (Q) at (axis cs:{(\v*cos(\ang)*\d+\s*\v*cos(\ang))},{\v*\d*sin(\ang)+0.5*\g*\d^2+\s*(\v*sin(\ang)+\g*\d)});
\draw[very thick,->](P)--(Q)
%node[midway,sloped,above]{$\vec{V}$}
;
\draw[densely dashed,very thick,->](P)--(Q|-P)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](P)--(Q-|P)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(P)};

%vector 3/4 down
\pgfmathsetmacro{\f}{{(-1*(2/\g)*\v*sin(\ang))*0.7}}
\coordinate (R) at (axis cs:{\v*cos(\ang)*\f},{\v*\f*sin(\ang)+0.5*\g*(\f^2)});
\coordinate (S) at (axis cs:{(\v*cos(\ang)*\f+\s*\v*cos(\ang))},{\v*\f*sin(\ang)+0.5*\g*\f^2+\s*(\v*sin(\ang)+\g*\f)});
\draw[very thick,->](R)--(S)
node[midway,above,sloped]{$\vec{V}$};
\draw[densely dashed,very thick,->](R)--(S|-R)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](R)--(S-|R)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(R)};

%vector 1/4 down
\pgfmathsetmacro{\e}{{(-1*(2/\g)*\v*sin(\ang))*0.8}}
\coordinate (T) at (axis cs:{\v*cos(\ang)*\e},{\v*\e*sin(\ang)+0.5*\g*(\e^2)});
\coordinate (U) at (axis cs:{(\v*cos(\ang)*\e+\s*\v*cos(\ang))},{\v*\e*sin(\ang)+0.5*\g*\e^2+\s*(\v*sin(\ang)+\g*\e)});
\draw[very thick,->](T)--(U)
node[midway,sloped,above]{$\vec{V}$};
\draw[densely dashed,very thick,->](T)--(U|-T)
node[midway,above]{$\vec{V}_x$};
\draw[densely dashed,very thick,->](T)--(U-|T)
node[midway,left]{$\vec{V}_y$};

\path plot[mark=*] coordinates {(T)};

%free fall comparison plots
\pgfmathsetmacro{\z}{{(\v*cos(\ang)*\c+\v*cos(\ang)*\c+\s*\v*cos(\ang))*.5}}

\draw[very thick,->] (axis cs:\z,{\v*\e*sin(\ang)+0.5*\g*(\e^2)}) -- (axis cs:\z,{\v*\e*sin(\ang)+0.5*\g*\e^2+\s*(\v*sin(\ang)+\g*\e)});
\draw[very thick,->] (axis cs:\z,{\v*\f*sin(\ang)+0.5*\g*(\f^2)}) -- (axis cs:\z,{\v*\f*sin(\ang)+0.5*\g*\f^2+\s*(\v*sin(\ang)+\g*\f)});
\draw[very thick,->] (axis cs:\z,{\v*\d*sin(\ang)+0.5*\g*(\d^2)}) -- (axis cs:\z,{\v*\d*sin(\ang)+0.5*\g*\d^2+\s*(\v*sin(\ang)+\g*\d)});
\draw[very thick,->] (axis cs:\z,{\v*\a*sin(\ang)+0.5*\g*(\a^2)}) -- (axis cs:\z,{\v*\a*sin(\ang)+0.5*\g*\a^2+\s*(\v*sin(\ang)+\g*\a)})
node[midway,right]{Vertical fall}
;
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\e*sin(\ang)+0.5*\g*(\e^2)})};
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\f*sin(\ang)+0.5*\g*(\f^2)})};
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\d*sin(\ang)+0.5*\g*(\d^2)})};
\path plot[mark=*] coordinates {(axis cs:\z,{\v*\a*sin(\ang)+0.5*\g*(\a^2)})};

\end{axis}
\end{tikzpicture}

答案1

尝试clip mode=individual代替clip=false

在此处输入图片描述

相关内容