I have an ordered hierarchy which I'd like to plot using Graphviz (or some other visualisation program).
Ideally the plot would draw the leading and trailing vector of a node and maintain the correct level in the hierarchy. What I'm most unsure of is how to maintain the levels of hierarchy since trailing vectors can return to their superior/parent.
If it is unclear what exactly I am asking for then at 47 minutes of this video https://www.youtube.com/watch?v=sWgDk-o-6ZE there is a picture in the presentation.
I'd like to know if it is possible and what the graphviz (.gv) file might look like.
Thanks!
I wrote a Prolog program to produce genealogical 'trees', like this one
Here the DB is small, but it works fairly well for larger data sets... the .gv computed by the program, submitted to Graphviz for rendering:
digraph "graph_window" {
node [
style = "radial"
fillcolor = "white"
shape = "ellipse"
label = ""
]
edge [
arrowhead = "vee"
]
subgraph "1" {
rank = "same"
rankdir = "LR"
subgraph "['Cecilia Cavendish-Bentinck','Claude Bowes-Lyon']" {
"'Cecilia Cavendish-Bentinck'" [
fillcolor = "white:red"
label = "Cecilia Cavendish-Bentinck"
]
"'Claude Bowes-Lyon'" [
fillcolor = "white:green"
label = "Claude Bowes-Lyon"
]
}
subgraph "['George V','Princess Mary of Teck']" {
"'George V'" [
fillcolor = "white:green"
label = "George V"
]
"'Princess Mary of Teck'" [
fillcolor = "white:red"
label = "Princess Mary of Teck"
]
}
}
subgraph "2" {
rank = "same"
rankdir = "LR"
subgraph "['George VI','Lady Elizabeth Bowes-Lyon']" {
"'George VI'" [
fillcolor = "white:green"
label = "George VI"
]
"'Lady Elizabeth Bowes-Lyon'" [
fillcolor = "white:red"
label = "Lady Elizabeth Bowes-Lyon"
]
}
"'Rose Bowes-Lyon'" [
fillcolor = "white:red"
label = "Rose Bowes-Lyon"
]
}
subgraph "3" {
rank = "same"
rankdir = "LR"
"'Elizabeth II'" [
fillcolor = "white:red"
label = "Elizabeth II"
]
}
"['George V','Princess Mary of Teck']" [
shape = "point"
width = "0.1"
height = "0.1"
]
"['Cecilia Cavendish-Bentinck','Claude Bowes-Lyon']" [
shape = "point"
width = "0.1"
height = "0.1"
]
"['George VI','Lady Elizabeth Bowes-Lyon']" [
shape = "point"
width = "0.1"
height = "0.1"
]
"'George V'" -> "['George V','Princess Mary of Teck']" [
]
"'Princess Mary of Teck'" -> "['George V','Princess Mary of Teck']" [
]
"['George V','Princess Mary of Teck']" -> "'George VI'" [
]
"'Cecilia Cavendish-Bentinck'" -> "['Cecilia Cavendish-Bentinck','Claude Bowes-Lyon']" [
]
"'Claude Bowes-Lyon'" -> "['Cecilia Cavendish-Bentinck','Claude Bowes-Lyon']" [
]
"['Cecilia Cavendish-Bentinck','Claude Bowes-Lyon']" -> "'Lady Elizabeth Bowes-Lyon'" [
]
"['Cecilia Cavendish-Bentinck','Claude Bowes-Lyon']" -> "'Rose Bowes-Lyon'" [
]
"'George VI'" -> "['George VI','Lady Elizabeth Bowes-Lyon']" [
]
"'Lady Elizabeth Bowes-Lyon'" -> "['George VI','Lady Elizabeth Bowes-Lyon']" [
]
"['George VI','Lady Elizabeth Bowes-Lyon']" -> "'Elizabeth II'" [
]
}
that is, each layer goes into its own subgraph. I further used the subgraph to group pairs of parents.
Related
I'm trying to insert a location that is using a circle processor to generate the circle points. Location [30, 10] in the document is generated with the circle points properly.
docs: Circle processor | Elasticsearch Guide [8.5] | Elastic
PUT _ingest/pipeline/polygonize_circles
{
"description": "translate circle to polygon",
"processors": [
{
"circle": {
"field": "circle",
"error_distance": 1,
"shape_type": "geo_shape"
}
}
]
}
PUT circles
{
"mappings": {
"properties": {
"circle": {
"type": "geo_shape"
}
}
}
}
PUT circles/_doc/2?pipeline=polygonize_circles
{
"circle": {
"type": "circle",
"radius": "40m",
"coordinates": [35.539917, -78.472000]
}
}
GET circles/_doc/2
But if I use another location. The generated coordinate looks like an oval with the wrong radius.
my location [35.54171753710938, -78.472]
created coordinates:
"circle": {
"coordinates": [
[
[
35.54171753710938,
-78.472
],
[
35.54112406581135,
-78.47173430472324
],
[
35.540630197847186,
-78.47167003953963
],
[
35.540375564960186,
-78.47165140797998
],
[
35.54021828908823,
-78.47164529506406
],
[
35.54010640465818,
-78.47164274491611
],
[
35.54001650261309,
-78.47164162397662
],
[
35.53993651647515,
-78.47164003979641
],
[
35.539858062238046,
-78.47164049555624
],
[
35.53977439153409,
-78.47164207973975
],
[
35.5396750942597,
-78.47164321572573
],
[
35.5395458932956,
-78.47164846905713
],
[
35.539348254773515,
-78.47165779735127
],
[
35.53899878746994,
-78.47169061817682
],
[
35.53833938849573,
-78.47182842440924
],
[
35.53833938849573,
-78.47217157559075
],
[
35.53899878746994,
-78.47230938182317
],
[
35.539348254773515,
-78.47234220264872
],
[
35.5395458932956,
-78.47235153094286
],
[
35.5396750942597,
-78.47235678427425
],
[
35.53977439153409,
-78.47235792026024
],
[
35.539858062238046,
-78.47235950444374
],
[
35.53993651647515,
-78.47235996020358
],
[
35.54001650261309,
-78.47235837602337
],
[
35.54010640465818,
-78.47235725508388
],
[
35.54021828908823,
-78.47235470493592
],
[
35.540375564960186,
-78.47234859202001
],
[
35.540630197847186,
-78.47232996046036
],
[
35.54112406581135,
-78.47226569527675
],
[
35.54171753710938,
-78.472
]
]
],
"type": "Polygon"
}
coordinates mapping on google maps
Is it an issue or It's working as expected? Because the coordinates are not a circle so it's impacting the search result.
You need to specify your coordinate array using longitude first and then latitude, I think you did the opposite and your circle is in the middle of Antartica.
If you do it like this:
PUT circles/_doc/2?pipeline=polygonize_circles
{
"circle": {
"type": "circle",
"radius": "40m",
"coordinates": [-78.472000, 35.539917]
}
}
Then your circle doesn't look oval anymore:
From the official doc:
In GeoJSON and WKT, and therefore Elasticsearch, the correct coordinate order is longitude, latitude (X, Y) within coordinate arrays. This differs from many Geospatial APIs (e.g., Google Maps) that generally use the colloquial latitude, longitude (Y, X).
I am using graphviz to draw a construction of a tree step by step.
It shows like the following:
The tree should show from top to down, not left to right.
The constructing code of the above image:
digraph test1 {
subgraph cluster000005 {
node_1 [label="2, 4"]
node_2 [label=1]
node_1 -> node_2
node_3 [label=3]
node_1 -> node_3
node_4 [label=5]
node_1 -> node_4
label="add 5"
}
subgraph cluster000004 {
node_5 [label=2]
node_6 [label=1]
node_5 -> node_6
node_7 [label="3, 4"]
node_5 -> node_7
label="add 4"
}
subgraph cluster000003 {
node_8 [label=2]
node_9 [label=1]
node_8 -> node_9
node_10 [label=3]
node_8 -> node_10
label="add 3"
}
subgraph cluster000002 {
node_11 [label="1, 2"]
label="add 2"
}
subgraph cluster000001 {
node_12 [label=1]
label="add 1"
}
rankdir=LR
}
Is this what you are after?
remove rankdir statement
add invisible edges to stack clusters (vertically)
lots of fiddling to get clusters to align nicely - added surrounding clusters
This:
digraph test1 {
// added "invisible clusters" to get the "real clusters"
// to align vertically
// don't understand why this was necessary
subgraph clusterInvis1 {
subgraph cluster000005 {
node_1 [label="2, 4" ]
node_2 [label=1]
node_3 [label=3]
node_4 [label=5]
node_1 -> node_2
node_1 -> node_3
node_1 -> node_4
label="add 5"
}
subgraph clusterInvis2 {
subgraph cluster000004 {
node_5 [label=2]
node_6 [label=1]
node_7 [label="3, 4"]
node_5 -> node_6
node_5 -> node_7
label="add 4"
}
subgraph cluster000003 {
node_8 [label=2 ]
node_9 [label=1]
node_10 [label=3 ]
node_8 -> node_9
node_8 -> node_10
label="add 3"
}
peripheries=0 // place here for cluster only (not nodes)
}
peripheries=0 // place here for cluster only (not nodes)
}
subgraph cluster000002 {
node_11 [label="1, 2" ]
label="add 2"
}
subgraph cluster000001 {
node_12 [label=1 ]
label="add 1"
}
//rankdir=LR
edge [style=invis]
node_12 -> node_11 -> node_8
// shorthand to define two edges
{node_9 node_10} -> node_5
{node_6 node_7} -> node_1
}
Gives:
I want to create a graph that looks like this, i. e. where an edge goes from the node Manufacturer of means of production to the subgraph with the same name.
I wrote the following code for this:
digraph G {
rankdir=LR;
compound=true;
graph [fontname="Liberation Mono"];
node [fontname="Liberation Mono"];
edge [fontname="Liberation Mono"];
subgraph cluster0 {
label="System components";
mmp [label="Manufacturer of means of production", shape=box];
}
subgraph cluster1 {
t1start [label="Start of tact 1", shape=point]
t1end [label="End of tact 1", shape=point ]
subgraph cluster1_mmp {
label="Manufacturer of means of production"
cluster1_1 [label="Node 1", color=white]
subgraph cluster1_1_1 {
label="Technological cycle 1"
cluster1_1_1 [label="Node 2", color=white]
}
subgraph cluster1_1_2 {
label="Technological cycle 2"
cluster1_1_2 [label="Node 2", color=white]
}
}
}
subgraph cluster2 {
label="Такт 2"
t2start [label="Start of tact 2", shape=point]
t2end [label="End of tact 2", shape=point]
}
t1end -> t2start
mmp -> cluster1_1 [ltail=cluster1_mmp];
}
If I try to compile this code ("C:\Program Files (x86)\Graphviz2.38\bin\"dot.exe -Tpng -ograph.png graph.dot ), I get the warning Warning: mmp -> cluster1_1: tail not inside tail cluster cluster1_mmp.
How can I fix it and make the edge go to the subgraph?
Update 1:
Below you can find the image of the expected result -- an edge that goes from a node to a subgraph (subgraph, not a node inside the subgraph). This edge is red in the image below.
Update 2: Changed the code like shown below.
digraph G {
rankdir=LR;
compound=true;
graph [fontname="Liberation Mono"];
node [fontname="Liberation Mono"];
edge [fontname="Liberation Mono"];
subgraph cluster0 {
label="System components";
mmp [label="Manufacturer of means of production", shape=box];
}
subgraph cluster1 {
t1start [label="Start of tact 1", shape=point]
t1end [label="End of tact 1", shape=point ]
subgraph cluster1_mmp {
label="Manufacturer of means of production"
testNode [label="Node 1", color=white]
subgraph cluster1_1_1 {
label="Technological cycle 1"
cluster1_1_1 [label="Node 2", color=white]
}
subgraph cluster1_1_2 {
label="Technological cycle 2"
cluster1_1_2 [label="Node 2", color=white]
}
}
}
subgraph cluster2 {
label="Такт 2"
t2start [label="Start of tact 2", shape=point]
t2end [label="End of tact 2", shape=point]
}
t1end -> t2start
mmp -> cluster1 [ltail=cluster0, lhead=cluster1, label=" "];
}
You need to change your last line
mmp -> cluster1_1 [ltail=cluster1_mmp];
to
mmp -> cluster1_1 [lhead=cluster1 label=" "]
And then the graph comes as expected
Also if you want the edge to start from outside the box then you would do
mmp -> cluster1_1 [ltail=cluster0 lhead=cluster1 label=" "];
Edit
The final code used
digraph G {
rankdir=LR;
compound=true;
graph [fontname="Liberation Mono"];
node [fontname="Liberation Mono"];
edge [fontname="Liberation Mono"];
subgraph cluster0 {
label="System components";
mmp [label="Manufacturer of means of production", shape=box];
}
subgraph cluster1 {
t1start [label="Start of tact 1", shape=point]
t1end [label="End of tact 1", shape=point ]
subgraph cluster1_mmp {
label="Manufacturer of means of production"
cluster1_1 [label="Node 1", color=white]
subgraph cluster1_1_1 {
label="Technological cycle 1"
cluster1_1_1 [label="Node 2", color=white]
}
subgraph cluster1_1_2 {
label="Technological cycle 2"
cluster1_1_2 [label="Node 2", color=white]
}
}
}
subgraph cluster2 {
label="Такт 2"
t2start [label="Start of tact 2", shape=point]
t2end [label="End of tact 2", shape=point]
}
t1end -> t2start
mmp -> cluster1_1 [lhead=cluster1 label=" "]
}
The fiddle link for the same
Urm, did you just mean "lhead=cluster1_mmp" rather than ltail?
Your edge is specified as:
mmp -> cluster1_1 [ltail=cluster1_mmp];
The error message you have is "Warning: mmp -> cluster1_1: tail not inside tail cluster cluster1_mmp"
This says that your tail is not inside the tail cluster. The tail cluster is cluster1_mmp. cluster1_1, which is what you're trying to connect to is definitely inside cluster1_mmp. This explains your confusion.
Only after much investigation with a GraphvizFiddle did I eventually remember that with an arrow the pointy end is the head (that is, the syntax is tail -> head).
So, cluster1_1, the node you're trying to says is in cluster1_mmp is the head of the arrow. That's why your ltail specification isn't working. Changing it to lhead gets rid of the error message and generates a graph that looks like your picture. The arrow goes to the subgraph, exactly what you asked for in your question.
Here's are two GraphvizFiddles, one of the original code generating the original error and one with ltail changed to lhead which matches your picture.
(I'm sure I've spent ages debugging the same problem in my own graphs. Perhaps Graphviz could get an update to check if the the ltail parameter would make sense for the arrow head and vice versa and spit out a more helpful error message.)
The goal is to render an org-chart, where certain individuals have extra colored "labels" attached to them, representing their role in the scenario. Those labels are supposed to be directly to the left of the individual.
By making the individual and their labels part of a sub-graph, and then telling it that the labels and the person node are all {rank=same;...}, I was able to force the labels to appear where I wanted them.
However, there is a huge distance between the labels and the node that they are annotating. Nothing I have tried seems to fix it.
How do I make it so that the "label" nodes are as close to the node they are supposed to label as they are to one another?
digraph scenario {
outputorder=edgesfirst
rankdir=TB
graph [ splines=true ]
subgraph cluster_spec {
ranksep="0.25 equally"
style="filled";
bgcolor="#f7f7f7";
node [
style="filled",
fillcolor="#f7f7f7",
fontname="sans-serif",
fontsize="10",
shape=circle,
width="0.75in",
fixedsize="shape",
color="black"
]
manager [ label="manager", fillcolor="#00a000", fontcolor="#ffffff" ];
accessor [ label="accessor", fillcolor="#a00000", fontcolor="#ffffff" ];
submitter [ label="submitter", fillcolor="#ffff00", fontcolor="#000000" ];
owner [ label="owner", fillcolor="#0000a0", fontcolor="#ffffff" ];
backup [ label="backup", fillcolor="#a000a0", fontcolor="#ffffff" ];
{rank=same; "submitter" -> "accessor" [ color="#808080", dir="both" ]}
"manager" -> "submitter" [ color="black" ]
"owner" -> "submitter" [ color="black" ]
{rank=same; "submitter" -> "backup" [ color="#808080", dir="both" ]}
"manager" -> "accessor" [ color="black" ]
"owner" -> "accessor" [ color="black" ]
{rank=same; "accessor" -> "backup" [ label="same", color="red:green", dir="both" ]}
{rank=same; "manager" -> "owner" [ label="same", color="red:green", dir="both" ]}
"manager" -> "backup" [ color="black" ]
"owner" -> "backup" [ color="black" ]
}
subgraph cluster_final {
color=white;
ranksep="0.25 equally"
nodesep="0.125"
node [
fontname="sans-serif"
shape=circle,
style="filled",
fillcolor="#e7e7e7",
width="1.5in",
fixedsize=shape,
]
edge [
color="#000080",
headclip=true,
tailclip=true
]
subgraph "cluster_emma-7246-roles" {
{ rank=same;
"emma-7246-submitter" [ shape="cds", label="submitter", style="filled", fillcolor="#ffff00", height="0.75in", width="1.5in", fontcolor="#000000", fontsize="24"]
"emma-7246" [ label="emma-7246" ]
"emma-7246-submitter" -> "emma-7246" [ color="#f0f0f0", len="0.125" ];
}
}
subgraph "cluster_edmund-0712-roles" {
{ rank=same;
"edmund-0712-accessor" [ shape="cds", label="accessor", style="filled", fillcolor="#a00000", height="0.75in", width="1.5in", fontcolor="#ffffff", fontsize="24"]
"edmund-0712-backup" [ shape="cds", label="backup", style="filled", fillcolor="#a000a0", height="0.75in", width="1.5in", fontcolor="#ffffff", fontsize="24"]
"edmund-0712" [ label="edmund-0712" ]
"edmund-0712-accessor" -> "edmund-0712" [ color="#f0f0f0", len="0.125" ];
"edmund-0712-backup" -> "edmund-0712" [ color="#f0f0f0", len="0.125" ];
}
}
subgraph "cluster_emma-8949-roles" {
{ rank=same;
"emma-8949-manager" [ shape="cds", label="manager", style="filled", fillcolor="#00a000", height="0.75in", width="1.5in", fontcolor="#ffffff", fontsize="24"]
"emma-8949-owner" [ shape="cds", label="owner", style="filled", fillcolor="#0000a0", height="0.75in", width="1.5in", fontcolor="#ffffff", fontsize="24"]
"emma-8949" [ label="emma-8949" ]
"emma-8949-manager" -> "emma-8949" [ color="#f0f0f0", len="0.125" ];
"emma-8949-owner" -> "emma-8949" [ color="#f0f0f0", len="0.125" ];
}
}
"edmund-9898" -> "emma-8949"
"emma-8949" -> "edmund-0712"
"emma-8949" -> "emma-7246"
}
}
NOTE: If I take out the first subgraph, then the second one renders the way I expect it to. Something about the presence of the first subgraph is interfering with the layout and rendering of the second one.
I've been trying to get the x axis to display a text axis label. The example is here https://jsfiddle.net/z4aZ4/859/
I'd like "Question 1" displayed on the x axis. At the moment "Nan" is displayed.
var data =
[
{
"key": "Yes",
"color": "#d67777",
"values": [
{
"x" : "Question 1" ,
"y" : 70
} ,
{
"x" : "Question 2" ,
"y" : 65
}
]
},
{
"key": "No",
"color": "#4f99b4",
"values": [
{
"x" : "Question 1" ,
"y" : 30
} ,
{
"x" : "Question 2" ,
"y" : 35
}
]
}
]
You'll have to change the tick format to load your labels.
On the addGraph function:
Replace
.tickFormat(d3.format(',f'));
With
.tickFormat(function(d) { return d; });
Also so that a label will show up for each column you'll have to set reduceXTicks False:
var chart = nv.models.multiBarChart()
.reduceXTicks(false);