如何在不影响标签不透明度的情况下改变边缘不透明度(tikz-network)?

如何在不影响标签不透明度的情况下改变边缘不透明度(tikz-network)?

当我将边缘设为不透明时(使用tikz-network),标签也会变为不透明。如何单独调整标签的不透明度边缘

下图中$\frac{3}{4}\epsilon$是不透明的。

不透明边缘标签

这个问题与这里提出的问题很接近:如何在不影响角度标签的情况下改变填充不透明度?

以下代码重现了上面的图像:

\documentclass[preview]{standalone}
\usepackage{tikz-network}

\begin{document}
    \begin{center}
    \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (4,2);
    \Vertex[x=0.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pOne}
    \Vertex[x=1.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pTwo}
    \Vertex[x=2.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pThree}
    \Vertex[x=3.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pFour}
    \Vertex[x=4.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pFive}
    \Edge[color=red,opacity=0.5](pOne)(pTwo)
    \Edge[color=red,opacity=0.5](pTwo)(pThree)
    \Edge[color=red,opacity=0.5](pThree)(pFour)
    \Edge[color=red,opacity=0.5](pFour)(pFive)
    \Edge[color=red,opacity=0.25,bend=-45](pOne)(pThree)
    \Edge[color=red,opacity=0.25,bend=45](pTwo)(pFour)
    \Edge[color=red,fontcolor=black,opacity=0.25, bend=-45,label={$\frac{3}{4}\epsilon$}](pThree)(pFive)
    \end{tikzpicture}
    \end{center}
\end{document}

答案1

使用密钥尝试此代码text opacity

C

\documentclass[preview]{standalone}
\usepackage{tikz-network}

\begin{document}    

    \begin{center}
    \begin{tikzpicture}
        \useasboundingbox (0,0) rectangle (4,2);
        \Vertex[x=0.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pOne}
        \Vertex[x=1.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pTwo}
        \Vertex[x=2.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pThree}
        \Vertex[x=3.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pFour}
        \Vertex[x=4.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pFive}
        \Edge[color=red,opacity=0.5](pOne)(pTwo)
        \Edge[color=red,opacity=0.5](pTwo)(pThree)
        \Edge[color=red,opacity=0.5](pThree)(pFour)
        \Edge[color=red,opacity=0.5](pFour)(pFive)
        \Edge[color=red,opacity=0.25,bend=-45](pOne)(pThree)
        \Edge[color=red,opacity=0.25,bend=45](pTwo)(pFour)  
        \Edge[style={text opacity = 1, opacity=0.25},color=red,fontcolor=black, bend=-45, label={$\frac{3}{4}\epsilon$}](pThree)(pFive) % changed <<<<<<<<<<<<  
    \end{tikzpicture}
\end{center}

\end{document}

或者通过定义 tikz 样式来节省一些输入

\documentclass[preview]{standalone}
\usepackage{tikz-network}

\tikzset{EdgeOp50/.style={% added <<<<<<<<<<
    text opacity  = 1,
    opacity=0.5,
    color=red,  
}}
\tikzset{EdgeOp25/.style={% added <<<<<<<<<<
    text opacity  = 1,
    opacity=0.25,
    color=red,  
}}


\begin{document}    
    \begin{center}
        \begin{tikzpicture}
            \useasboundingbox (0,0) rectangle (4,2);
            \Vertex[x=0.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pOne}
            \Vertex[x=1.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pTwo}
            \Vertex[x=2.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pThree}
            \Vertex[x=3.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pFour}
            \Vertex[x=4.0, y=0.75,size=0.4,style={color=red},opacity=0.3,label=$+$]{pFive}
            \Edge[style={EdgeOp50}](pOne)(pTwo)
            \Edge[style={EdgeOp50}](pTwo)(pThree)
            \Edge[style={EdgeOp50}](pThree)(pFour)
            \Edge[style={EdgeOp50}](pFour)(pFive)
            \Edge[style={EdgeOp25},bend=-45](pOne)(pThree)
            \Edge[style={EdgeOp25},bend=45](pTwo)(pFour)    
            \Edge[style={EdgeOp25},fontcolor=black, bend=-45, label={$\frac{3}{4}\epsilon$}](pThree)(pFive) %           
        \end{tikzpicture}
    \end{center}
\end{document}

\SetEdgeStyle[TextOpacity=1, Opacity=0.25]也可以用于设置全局边缘样式。

相关内容