Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge labels along edge #21

Open
Breee opened this issue May 20, 2021 · 3 comments
Open

Edge labels along edge #21

Breee opened this issue May 20, 2021 · 3 comments
Assignees

Comments

@Breee
Copy link

Breee commented May 20, 2021

Greetings :)

I got the following graph:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-network}

\begin{document}
\begin{tikzpicture}
    \clip (0,0) rectangle (30.0,30.0);
    \Vertex[x=29.000,y=15.000,size=2.0,color={0,77,153},opacity=0.7,label=A0,fontcolor={230,230,230},fontscale=2.286,RGB]{A0}
    \Vertex[x=22.000,y=27.124,size=2.0,color={0,77,153},opacity=0.7,label=A4,fontcolor={230,230,230},fontscale=2.286,RGB]{A4}
    \Vertex[x=8.000,y=27.124,size=2.0,color={0,77,153},opacity=0.7,label=A3,fontcolor={230,230,230},fontscale=2.286,RGB]{A3}
    \Vertex[x=1.000,y=15.000,size=2.0,color={0,77,153},opacity=0.7,label=A1,fontcolor={230,230,230},fontscale=2.286,RGB]{A1}
    \Vertex[x=8.000,y=2.876,size=2.0,color={0,77,153},opacity=0.7,label=A5,fontcolor={230,230,230},fontscale=2.286,RGB]{A5}
    \Vertex[x=22.000,y=2.876,size=2.0,color={0,77,153},opacity=0.7,label=A2,fontcolor={230,230,230},fontscale=2.286,RGB]{A2}
    \Edge[,lw=3.6871,color=purple,opacity=0.4687143150544264,bend=-8.531,label=11968.5/32460.0: 0.37,Direct](A0)(A4)
    \Edge[,lw=3.2066,color=purple,opacity=0.4206628671185051,bend=-8.531,label=10408.7/32460.0: 0.32,Direct](A0)(A3)
    \Edge[,lw=6.0346,color=purple,opacity=0.7034586157321837,bend=-8.531,label=19588.3/32460.0: 0.60,Direct](A0)(A1)
    \Edge[,lw=1.2568,color=purple,opacity=0.22568186485931396,bend=-8.531,label=4079.6/32460.0: 0.13,Direct](A0)(A5)
    \Edge[,lw=1.5525,color=purple,opacity=0.25524799753542815,bend=-8.531,label=5039.3/32460.0: 0.16,Direct](A0)(A2)
    \Edge[,lw=2.9291,color=purple,opacity=0.39291401533692316,bend=-8.531,label=11968.5/40860.0: 0.29,Direct](A4)(A0)
    \Edge[,lw=3.6119,color=purple,opacity=0.4611890194158921,bend=-8.531,label=14758.2/40860.0: 0.36,Direct](A4)(A3)
    \Edge[,lw=6.6366,color=purple,opacity=0.763656387665199,bend=-8.531,label=27117.0/40860.0: 0.66,Direct](A4)(A1)
    \Edge[,lw=1.9087,color=purple,opacity=0.29087045194974714,bend=-8.531,label=7799.0/40860.0: 0.19,Direct](A4)(A2)
    \Edge[,lw=3.4455,color=purple,opacity=0.44454540439148216,bend=-8.531,label=10408.7/30210.0: 0.34,Direct](A3)(A0)
    \Edge[,lw=4.8852,color=purple,opacity=0.5885198058038182,bend=-8.531,label=14758.2/30210.0: 0.49,Direct](A3)(A4)
    \Edge[,lw=7.1194,color=purple,opacity=0.8119392033542985,bend=-8.531,label=21507.7/30210.0: 0.71,Direct](A3)(A1)
    \Edge[,lw=1.132,color=purple,opacity=0.21319651329581812,bend=-8.531,label=3419.7/30210.0: 0.11,Direct](A3)(A5)
    \Edge[,lw=2.522,color=purple,opacity=0.3522029129427343,bend=-8.531,label=7619.1/30210.0: 0.25,Direct](A3)(A2)
    \Edge[,lw=2.9965,color=purple,opacity=0.3996522359900059,bend=-8.531,label=19588.3/65370.0: 0.30,Direct](A1)(A0)
    \Edge[,lw=4.1482,color=purple,opacity=0.5148233134465356,bend=-8.531,label=27117.0/65370.0: 0.41,Direct](A1)(A4)
    \Edge[,lw=3.2901,color=purple,opacity=0.4290145836520324,bend=-8.531,label=21507.7/65370.0: 0.33,Direct](A1)(A3)
    \Edge[,lw=1.9365,color=purple,opacity=0.29364514813115106,bend=-8.531,label=12658.6/65370.0: 0.19,Direct](A1)(A2)
    \Edge[,lw=4.945,color=purple,opacity=0.5945010101010099,bend=-8.531,label=4079.6/8250.0: 0.49,Direct](A5)(A0)
    \Edge[,lw=4.145,color=purple,opacity=0.5145010101010101,bend=-8.531,label=3419.6/8250.0: 0.41,Direct](A5)(A4)
    \Edge[,lw=4.1451,color=purple,opacity=0.5145050505050504,bend=-8.531,label=3419.7/8250.0: 0.41,Direct](A5)(A3)
    \Edge[,lw=6.6902,color=purple,opacity=0.7690242424242423,bend=-8.531,label=5519.4/8250.0: 0.67,Direct](A5)(A1)
    \Edge[,lw=2.7269,color=purple,opacity=0.3726929292929293,bend=-8.531,label=2249.7/8250.0: 0.27,Direct](A5)(A2)
    \Edge[,lw=2.3138,color=purple,opacity=0.33137511478420556,bend=-8.531,label=5039.3/21780.0: 0.23,Direct](A2)(A0)
    \Edge[,lw=3.5808,color=purple,opacity=0.45807927762473233,bend=-8.531,label=7799.0/21780.0: 0.36,Direct](A2)(A4)
    \Edge[,lw=3.4982,color=purple,opacity=0.4498186409550048,bend=-8.531,label=7619.1/21780.0: 0.35,Direct](A2)(A3)
    \Edge[,lw=5.812,color=purple,opacity=0.6812021732476283,bend=-8.531,label=12658.6/21780.0: 0.58,Direct](A2)(A1)
    \Edge[,lw=1.0329,color=purple,opacity=0.20329277624732173,bend=-8.531,label=2249.7/21780.0: 0.10,Direct](A2)(A5)
    \end{tikzpicture}   
\end{document}

PDF: test2.pdf

How can I achieve that the edge labels are (1) always along the edges and (2) manipulate the size of the white circle around the edge labels?

Similar to this graph: text.pdf

@hackl hackl self-assigned this May 25, 2021
@hackl
Copy link
Owner

hackl commented May 25, 2021

Thank you for sharing this issue. I will have a look and see if I find a solution to fix it.

@Breee
Copy link
Author

Breee commented May 25, 2021

Thanks, that would be great :)

@hackl
Copy link
Owner

hackl commented Jun 7, 2021

Hi, the easiest way to customize the edge labels is to change the EdgeLabelStyle. The default options can be overwritten by appending new styles (see example below).

In the next version of tikz-network I will add a dedicated command to make this easier for the users.

\documentclass{standalone}

% Used packages
\usepackage{tikz-network}

% Change the default EdgeLabelStyle
\tikzset{EdgeLabelStyle/.append style={ % add styles to te existing EdgeLabelStyle
    rectangle,                          % make the bounding box rectangular
    rounded corners,                    % round the corners of the box
    fill=black!30,                      % add some nice background color
    sloped,                             % align the text with the edge
    inner sep=1pt                       % add a little space around the text
  }}

\begin{document}
\begin{tikzpicture}

% Vertices
\Vertex[size=.4,color=green,opacity=.9,label=a]{A}
\Vertex[x=4,y=.7,opacity=.5,label=b]{B}

% Edges
\Edge[label={This is a very long text},lw=.5,color=red](A)(B)

\end{tikzpicture}
\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants