
我有以下 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}
我想把範圍改為xshift
3cm。問題在於,這些圓圈與位於左圓圈上方的右圓圈重疊。我希望顏色強度能夠有建設性地增加。
一個單獨的問題:如何在沒有軸的圓上加入高斯函數?我在 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}