我正在尝试绘制此图
这就是我要去的地方,但我仍在努力弄清楚如何添加颜色。
平均能量损失
\documentclass{article}
\usepackage{karnaugh-map}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[hide axis,
plot box ratio = 1 6 1,
view = {0}{15}]
\addplot3[surf,
samples=20,
domain=0:2*pi,y domain=0:2*pi,
z buffer=sort]
({(2+cos(deg(x)))*cos(deg(y+pi/2))},
{(2+cos(deg(x)))*sin(deg(y+pi/2))},
{sin(deg(x))});
\end{axis}
\end{tikzpicture}
%
\begin{karnaugh-map}[4][4][1][][]
\end{karnaugh-map}
\end{document}
颜色代码
0000 - #F70400
0100 - #AA0154
1100 - #5600AB
1000-#0003FB
0001 - #FF5500
0101 - #AA5455
1101 - #5555AB
1001 - #0055FE
0011 - #FFAA01
0111 - #AAA956
1111 - #56AAAA
1011 - #00AAFF
0010 - #FEFF02
0110 - #A9FF54
1110 - #55FFAA
1010 - #0FF6FF
答案1
谢谢你的色彩!我没有时间调整细节。
\documentclass{article}
\usepackage[rgb]{xcolor}
\usepackage{karnaugh-map}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\definecolor{mycolor0000}{HTML}{F70400}
\definecolor{mycolor0100}{HTML}{AA0154}
\definecolor{mycolor1100}{HTML}{5600AB}
\definecolor{mycolor1000}{HTML}{0003FB}
\definecolor{mycolor0001}{HTML}{FF5500}
\definecolor{mycolor0101}{HTML}{AA5455}
\definecolor{mycolor1101}{HTML}{5555AB}
\definecolor{mycolor1001}{HTML}{0055FE}
\definecolor{mycolor0011}{HTML}{FFAA01}
\definecolor{mycolor0111}{HTML}{AAA956}
\definecolor{mycolor1111}{HTML}{56AAAA}
\definecolor{mycolor1011}{HTML}{00AAFF}
\definecolor{mycolor0010}{HTML}{FEFF02}
\definecolor{mycolor0110}{HTML}{A9FF54}
\definecolor{mycolor1110}{HTML}{55FFAA}
\definecolor{mycolor1010}{HTML}{0FF6FF}
\pgfplotsset{colormap={BR}{%
color(0)=(mycolor0000) color(1)=(mycolor0100) color(2)=(mycolor1100) color(3)=(mycolor1000)
color(4)=(mycolor0001) color(5)=(mycolor0101) color(6)=(mycolor1101) color(7)=(mycolor1001)
color(8)=(mycolor0011) color(9)=(mycolor0111) color(10)=(mycolor1111) color(11)=(mycolor1011)
color(12)=(mycolor0010) color(13)=(mycolor0110) color(14)=(mycolor1110) color(15)=(mycolor1010)
}}
\begin{document}
\begin{tikzpicture}[font=\small\sffamily]
\begin{axis}
[hide axis,shader=flat corner,%colormap name=BR,
plot box ratio = 1 6 1,
view = {0}{15}]
\addplot3[surf,
samples=32,point meta={int(mod(-atan2(y,x)+45+360,360)/90)+
4*int(mod(atan2(z,sqrt(x^2+y^2)-2)+360+180,360)/90)
},domain=0:360,y domain=0:360,
z buffer=sort]
({(2+cos(x))*cos(y+90)},
{(2+cos(x))*sin(y+90)},
{sin(x)});
\node at ({(2+cos(45))*cos(-90)},{(2+cos(45))*sin(-90)},{cos(45)}) {0111};
\node at ({(2+cos(45))*cos(-90)},{(2+cos(45))*sin(-90)},{0.15-cos(45)}) {0101};
\fill ({(2-cos(45))*cos(90-50)},{(2-cos(45))*sin(90-50)},{cos(80)}) circle (1mm);
\end{axis}
\end{tikzpicture}
%
\begin{karnaugh-map}[4][4][1][][]
\end{karnaugh-map}
\end{document}