
페이딩으로 채워진 두 개의 원을 그리는 다음 MWE가 있습니다.
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[inner color=red,outer color=white] (0,0) circle (1.8);
\begin{scope}[xshift=4cm]
\fill[inner color=red,outer color=white] (0,0) circle (1.8);
\end{scope}
\end{tikzpicture}
\end{document}
범위를 3cm로 변경하고 싶습니다 xshift
. 문제는 원이 왼쪽 원 위에 놓인 오른쪽 원과 겹쳐진다는 것입니다. 대신에 색상 강도를 건설적으로 추가하고 싶습니다.
별도의 질문: 축 없이 원 위에 가우스 함수를 어떻게 추가할 수 있나요? TikZ 사이트에서 본 예제에서는 축을 그리는 pgfplots 패키지를 사용했습니다.
답변1
우리는 fadings
라이브러리를 사용합니다( \tikzfading
PGF/TikZ 매뉴얼에서 문서를 검색하세요.)
출력
빨간색 디스크 둘 다 별로 안 예쁜 것 같아서 하나는 파란색으로 바꿨어요.
코드
\documentclass[tikz]{standalone}
\usetikzlibrary{fadings}
\tikzfading %strangely gives bad bounding box when inside the tikzpicture
[
name=fade out,
inner color=transparent!0,
outer color=transparent!100
]
\begin{document}
\begin{tikzpicture}
\tikzset
{
myCircle/.style=
{
red,
path fading=fade out,
}
}
\def\a{1}
\fill[myCircle] (-\a,0) circle (1.8);
\fill[myCircle, blue,] (\a,0) circle (1.8);
\draw plot [samples=200] (\x, {exp(-.5*(\x)^2)}) ;
\end{tikzpicture}
\end{document}
답변2
어떻게 작동하는지 조금 잘 모르겠지만 Fadings
TikZ 매뉴얼 섹션 23.4가 필요하다고 생각합니다. 이 같은:
\documentclass[border=0.2 cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\tikzfading[name=fade inside,
inner color=transparent!0,
outer color=transparent!30]
\begin{tikzpicture}
\shade[ball color=red,path fading=fade inside] (0,0) circle (1.8);
\begin{scope}[xshift=3cm]
\shade[ball color=red,path fading=fade inside] (0,0) circle (1.8);
\end{scope}
\end{tikzpicture}
\end{document}