How to bind tree / graph / web data to gnuplot?

I have a dataset consisting of edges and colors, and I want to draw them in a web, with lines and circles, such as the picture below, and possibly with cluster coloring.

Graph example

The data is organized as follows:

point1a_x point1a_y color point1b_x point1b_y color point2a_x point2a_y color point2b_x point2b_y color (...) point2n_x point2n_y color point2n_x point2n_y color 

How will I do this on gnuplot?

+8
graph plot tree gnuplot nodes
source share
2 answers

The answer is not entirely accepted for me. Here's how I had to change it:

Input file format

 # A vertex has 3 fields: x coordinate, y coordnate and the label # An edge consists of two points in consecutive lines # There must be one or more blank lines between each edge. 21.53 9.55 A 24.26 7.92 B 5.63 3.23 C 2.65 1.77 D 5.63 3.23 C 4.27 7.04 E #... 

The big difference compared to the other answer is that the labels belong to the vertices, not the edges.

Also note that I changed the labels to letters instead of numbers. Labels can be any string, and this gives a clearer idea that they are not consecutive indexes in this example.

Build team

 plot \ 'edges.dat' using 1:2 with lines lc rgb "black" lw 2 notitle,\ 'edges.dat' using 1:2:(0.6) with circles fill solid lc rgb "black" notitle,\ 'edges.dat' using 1:2:3 with labels tc rgb "white" offset (0,0) font 'Arial Bold' notitle 

The big change is that now when building inscriptions we create a third field instead of the $0 field, which is the serial number.

+3
source share

Ok, so I figured it out myself, and I will leave the details here to help anyone with the same questions.

Graph of one color with labels on nodes:

This will create a graph similar to the one asked for the question, with lines connecting the circles with the labels inside.

Single color graph with labels on the nodes

 plot 'edges.dat' u 1:2 with lines lc rgb "black" lw 2 notitle,\ 'edges.dat' u 1:2:(0.6) with circles fill solid lc rgb "black" notitle,\ 'edges.dat' using 1:2:($0) with labels tc rgb "white" offset (0,0) font 'Arial Bold' notitle 

With minor changes, it can be compared with the image of the question.

enter image description here

 plot 'edges.dat' u 1:2 with lines lc rgb "black" lw 2 notitle,\ 'edges.dat' u 1:2:(0.8) with circles linecolor rgb "white" lw 2 fill solid border lc lt 0 notitle, \ 'edges.dat' using 1:2:($0) with labels offset (0,0) font 'Arial Bold' notitle 

Cluster color graph:

Cluster-colored graph

 unset colorbox set palette model RGB defined ( 0 0 0 0 , 1 1 0 0 , 2 1 0.9 0, 3 0 1 0, 4 0 1 1 , 5 0 0 1 , 6 1 0 1 ) plot 'edges.dat' u 1:2:3 with lines lc palette notitle,\ 'edges.dat' u 1:2:(0.15):3 with circles fill solid palette notitle 

The data used on all graphs follows this structure:

 21.53 9.55 0 24.26 7.92 0 5.63 3.23 1 2.65 1.77 1 5.63 3.23 0 4.27 7.04 0 (...) 
+7
source share

All Articles