Manim(애니메이션을 수행하는 3b1b 프로그래밍 언어)에서는 배경이 검은색인 아름다운 애니메이션을 얻을 수 있습니다. LaTeX에서는 Tikz
?
예를 들면 다음과 같습니다. 이 그림을 그리고 싶지만 배경은 검정색입니다.
\begin{tikzpicture}[
point/.style={circle,fill,inner sep=1.3pt}]
\draw[thin, dashed, black!50!] (0,0) -- (8,0);
\begin{scope}[rotate around={15:(8:0)}]
\draw[thin, black] (0,0) -- (8,0);
\draw[fill, gray!40] (2,0) rectangle (4,1);
\draw[black] (2,0) rectangle (4,1);
\draw (3,0.5) node{$\bullet$}node[above,right]{$G$};
\draw[dashed, black] (3,0) -- (3,3);
\draw[thick, black, ->] (3,0) -- (2.4,1.5) node[above]{$\vec{R}$};
\coordinate(y) at (3,0);
\coordinate(x) at (3,1.5);
\coordinate(z) at (2.6,1);
\pic [draw=black!15!black,text=black,angle radius=9mm,"$\varphi$",angle eccentricity=1.3, ->]{angle = x--y--z};
\end{scope}
\draw[thick, black,->] (2.86,1)--(2.86,0) node[above,right]{$\vec{P}$};
\coordinate(o) at (0,0);
\coordinate(i) at (2,0.5);
\coordinate(j) at (2,0);
\pic [draw=black!15!black,text=black,angle radius=9mm,"$\alpha$",angle eccentricity=1.3, ->]{angle = j--o--i};
\end{tikzpicture}
답변의 코드는 다음과 같습니다.
\begin{tikzpicture}[]
\begin{axis}[
xmin = -4.9, xmax = 5.1,
%ymin = -3.5, ymax = 3.5,
restrict y to domain=-6:6,
axis lines = middle,
axis line style={-latex},
xlabel={$x$},
ylabel={$y$},
%enlarge x limits={upper={val=0.2}},
enlarge y limits=0.05,
x label style={at={(ticklabel* cs:1.00)}, inner sep=5pt, anchor=north},
y label style={at={(ticklabel* cs:1.00)}, inner sep=2pt, anchor=south east},
]
\addplot[color=red, samples=222, smooth,
domain = 0:5] gnuplot{gamma(x)};
\foreach[evaluate={\N=\n-1}] \n in {0,...,-5}{%
\addplot[color=red, samples=555, smooth,
domain = \n:\N] gnuplot{gamma(x)};
%
\addplot [domain=-6:6, samples=2, densely dashed, thin] (\N, x);
}%
\end{axis}
\end{tikzpicture}
검은색 배경의 "어두운 테마"로 이 그림을 만드는 방법이 있나요?
답변1
일반적으로 쉬운 접근 방식은 라이브러리를 tikzpicture
통해 배경을 추가하는 것입니다 backgrounds
. 첫 번째 예에서는 다음과 같이 할 수 있습니다(작업을 수행할 수는 없었지만 \pic
이해하게 될 것입니다).
\documentclass[tikz]{standalone}
\usetikzlibrary{angles,backgrounds}
\begin{document}
\begin{tikzpicture}[
point/.style={circle,fill,inner sep=1.3pt},background rectangle/.style={fill=black}, show background rectangle]
\draw[thin, dashed, black!50!] (0,0) -- (8,0);
\begin{scope}[rotate around={15:(8:0)}]
\draw[thin, white] (0,0) -- (8,0);
\draw[fill, gray!40] (2,0) rectangle (4,1);
\draw[white] (2,0) rectangle (4,1);
\draw[white] (3,0.5) node{$\bullet$}node[above,right]{$G$};
\draw[dashed, white] (3,0) -- (3,3);
\draw[thick, white, ->] (3,0) -- (2.4,1.5) node[above]{$\vec{R}$};
\coordinate(y) at (3,0);
\coordinate(x) at (3,1.5);
\coordinate(z) at (2.6,1);
%\pic [draw=black!15!black,text=black,angle radius=9mm,"$\varphi$",angle eccentricity=1.3, ->]{angle = x--y--z};
\end{scope}
\draw[thick, white,->] (2.86,1)--(2.86,0) node[above,right]{$\vec{P}$};
\coordinate(o) at (0,0);
\coordinate(i) at (2,0.5);
\coordinate(j) at (2,0);
%\pic [draw=black!15!black,text=black,angle radius=9mm,"$\alpha$",angle eccentricity=1.3, ->]{angle = j--o--i};
\end{tikzpicture}
\end{document}
결과는 다음과 같습니다.