使用 tikz-network,我生成了网络图。边缘标签似乎留下了圆形的白色背景。当边缘标签重叠时,无法读取标签。我尝试了以下边缘样式设置:绘制不透明度 = 1、填充不透明度 = 0、文本不透明度 = 1}。
\documentclass{standalone}
\usepackage{tikz-network}
\begin{document}
\begin{tikzpicture}
\Vertex[x=0.950,y=0.950,size=1.8,color={44.0,160.0,44.0},RGB]{1111_0}
\Vertex[x=12.975,y=4.030,size=1.078,color={227.0,119.0,194.0},RGB]{0111_1}
\Vertex[x=12.975,y=2.490,size=0.819,color={188.0,189.0,34.0},RGB]{1011_1}
\Vertex[x=12.975,y=5.570,size=1.467,color={44.0,160.0,44.0},RGB]{1101_1}
\Vertex[x=12.975,y=7.110,size=0.835,color={227.0,119.0,194.0},RGB]{1110_1}
\Edge[,lw=0.035,label=0.035,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(1110_1)
\Edge[,lw=0.667,label=0.667,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(1101_1)
\Edge[,lw=0.278,label=0.278,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(0111_1)
\Edge[,lw=0.019,label=0.019,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(1011_1)
\end{tikzpicture}
\end{document}
我该如何修复这个问题以避免边缘标签出现圆形白色阴影?
答案1
由于某种原因EdgeLabelStyle
被定义为与circle
形状。
如果你通过使用来改变它
\tikzset{EdgeLabelStyle/.append style={shape=rectangle}}
代码
\documentclass{standalone}
\usepackage{tikz-network}
\tikzset{EdgeLabelStyle/.append style={shape=rectangle}}
\begin{document}
\begin{tikzpicture}
\Vertex[x=0.950,y=0.950,size=1.8,color={44.0,160.0,44.0},RGB]{1111_0}
\Vertex[x=12.975,y=4.030,size=1.078,color={227.0,119.0,194.0},RGB]{0111_1}
\Vertex[x=12.975,y=2.490,size=0.819,color={188.0,189.0,34.0},RGB]{1011_1}
\Vertex[x=12.975,y=5.570,size=1.467,color={44.0,160.0,44.0},RGB]{1101_1}
\Vertex[x=12.975,y=7.110,size=0.835,color={227.0,119.0,194.0},RGB]{1110_1}
\Edge[,lw=0.035,label=0.035,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(1110_1)
\Edge[,lw=0.667,label=0.667,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(1101_1)
\Edge[,lw=0.278,label=0.278,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(0111_1)
\Edge[,lw=0.019,label=0.019,distance=0.1,style={sloped, draw opacity=1 ,fill opacity=0, text opacity=1},Direct](1111_0)(1011_1)
\end{tikzpicture}
\end{document}
也就是说,graphs
图书馆也可以做到这一点。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{graphs}
\definecolor{greal} {RGB}{ 44,160, 44} % somewhere between green and teal
\definecolor{darkyellow}{RGB}{188,189, 34}
\definecolor{purkle} {RGB}{227,119,194} % somewhere between pink and purple
\tikzset{
network/.style={
graphs/every graph/.append style={
no placement, empty nodes,
edge quotes={
sloped, fill=white, fill opacity=.9, text opacity=1,
inner sep=+.1em, node font=\footnotesize, pos=.2},
nodes=/tikz/network/vertex, edges=/tikz/network/edge}},
network/vertex/.style={
shape=circle, draw, fill=none, thick, inner sep=+0pt,
size/.style={/pgf/minimum size={(##1)*1cm}}, size=1,
/tikz/color/.style={/tikz/fill={##1}}},
network/edge/.style={
lw/.style={/tikz/line width={(##1)*1pt}},
lwl/.style={
/tikz/lw={##1}, /tikz/edge node={node[every edge quotes]{$##1$}}}}}
\begin{document}
\tikz[network]\graph{
1111_0 [x=0.950, y=0.950, size=1.8, color=greal] -- {
0111_1[x=6.975, y=4.030, size=1.078, color=purkle, > lwl = 0.278],
1011_1[x=6.975, y=2.490, size=0.819, color=darkyellow, > lwl = 0.019],
1101_1[x=6.975, y=5.570, size=1.467, color=greal, > lwl = 0.667],
1110_1[x=6.975, y=7.110, size=0.835, color=purkle, > lwl = 0.035]
}
};
\end{document}