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:

ここに画像の説明を入力してください

関連情報