Tikz - 如何在这些形状周围添加边框线?

Tikz - 如何在这些形状周围添加边框线?

是否可以在这里画一条轮廓线或边界线,在黄色、红色和蓝色形状周围画一条黑线?(即在边缘周围画一条粗线)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,shapes.misc, positioning,shapes.geometric,arrows,matrix,fit,calc}
    \tikzset{
    buffer/.style={
        isosceles triangle,
        isosceles triangle apex angle=66,
        shape border rotate=90,
        fill=blue!20,
        node distance=5cm,
        rounded corners=60pt,
        opacity=0.6,
        minimum height=6cm
    }
}
\begin{document} 
\begin{tikzpicture}[font=\sffamily\sansmath]

 \tikzset{venn circle/.style={circle,minimum width=9mm,fill=#1,opacity=0.6}}

\node at (0,0) {A};
\node (ABC) at (0,-2        ) {ABC};
\node (B) at (-2,-3) {B};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\node (C) at (2,-3) {C};


\node[buffer]at (0,-1.9){};



\draw [line width=35pt,opacity=0.6,blue,line cap=round,rounded corners] (A.center) -- (AC.center) -- (C.center);
\draw [line width=35pt,opacity=0.6,yellow,line cap=round,rounded corners] (C.center) -- (BC.center) -- (B.center);
\draw [line width=35pt,opacity=0.6,red,line cap=round,rounded corners] (A.center) -- (AB.center) -- (B.center);



\node[venn circle = green, thick] at (0,0) {A};
\node (ABC) at (0,-2        ) {ABC};
\node[venn circle = green, thick] (B) at (-2,-3) {B};
\node (AB) at (-1,-1.5) {AB};
\node (AC) at (1,-1.5) {AC};
\node (BC) at (0,-3) {BC};
\node[venn circle = green, thick]  (C) at (2,-3) {C};


\end{tikzpicture}
\end{document}

我的尝试仅如下所示: 我的尝试

但我想要更像这样的东西(但这看起来很混乱而且很糟糕): 想要喜欢

答案1

嗯,对你的问题的回答稍微修改一下如何在两个节点周围创建进入链接......。我进一步简化了代码,并添加了节点间链接着色选项。链接被设计为节点。这样可以让链接的边框与填充颜色不同。

\documentclass[border=3mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{arrows.meta,calc,fit,positioning,
                shapes.geometric,shapes.misc}

\pgfdeclarelayer{foreground} 
\pgfdeclarelayer{background}
   \pgfsetlayers{background,%
                 main,%
                 foreground%
                 }

\begin{document}
    \begin{tikzpicture}[
         vc/.style = {%venn circle
    circle, draw, thick, fill=#1,
                      minimum width=9mm, opacity=0.6},
   vg/.style args = {#1/#2}{%venn group
    minimum height=11mm,
    minimum width=#1+\pgfkeysvalueof{/pgf/minimum height},
    draw, rounded corners=\pgfkeysvalueof{/pgf/minimum height}/2, 
    fill=#2!40, opacity=0.6,
    sloped}, 
                        ]
    \begin{pgfonlayer}{foreground}

\node (A) [vc=green]  at (0,0)    {A};
\node (B) [vc=green]  at (-2,-3)  {B};
\node (C) [vc=green]  at (2,-3)   {C};
\node (ABC) at (0,-2)       {ABC};
\node (AB)  at (-1,-1.5)    {AB};
\node (AC)  at (1,-1.5)     {AC};
\node (BC)  at (0,-3)       {BC};
    \end{pgfonlayer}
    \begin{pgfonlayer}{main}
\path   let \p1 = ($(A.center)-(B.center)$),
            \n1 = {veclen(\y1,\x1)} in
            (A) -- node[vg=\n1/blue] {} (B);
\path   let \p2 = ($(A.center)-(C.center)$),
            \n2 = {veclen(\y2,\x2)} in
            (A) -- node[vg=\n2/red] {} (C);
\path   let \p3 = ($(B.center)-(C.center)$),
            \n3 = {veclen(\y3,\x3)} in
            (B) -- node[vg=\n3/yellow] {} (C);
    \end{pgfonlayer}
    \begin{pgfonlayer}{background}
\draw[line width=16mm, draw=blue!20,fill=blue!20,rounded corners]
    (A.center)  -- (B.center) -- (C.center) -- cycle;
    \end{pgfonlayer}
\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑: 与您的 MWE 相比,上述示例有以下变化

  • 图像绘制在三个图层上;因此只有主图层上的链接才需要透明度
  • 节点在前面
  • 三角形位于背景层上

  • 所有图像元素都定义样式;这样代码就变得更短了

  • 所有节点都只设置一个
  • 链接使用节点,它由链接节点之间的路径定向。为此,需要测量节点宽度
  • 我没有定义蓝色三角形,而是buffer简单地用足够的颜色和填充颜色画出线条,
  • 对于我仅使用的字体\sffamily\sansmath导致错误

附录:为了在“蓝色”三角形周围制作边框线,您可以在节点周围添加一条线:

    \begin{pgfonlayer}{background}
\draw[line width=16.4mm, rounded corners]% <--- added for black borders
    (A.center)  -- (B.center) -- (C.center) -- cycle;
\draw[line width=16mm, draw=blue!20,fill=blue!20,rounded corners]
    (A.center)  -- (B.center) -- (C.center) -- cycle;
    \end{pgfonlayer}

结果是:

在此处输入图片描述

相关内容