Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alpha for fill color in DiagrammR

Tags:

r

diagrammer

I am trying to use the node attribute 'alpha' in a grViz but I can't get it to work (in RStudio) using R3.5.1 and all packages updated. This code produces no alpha.

library(DiagrammeR)

grViz("
digraph  {
node [fontname = Helvetica, 
    shape = rectangle,  width = 3,
    color = red, 
    alpha = 20,
    style = filled 
    ]

edge [color = red,  arrowtail = none]

A [width = 3, label = '@@1']
B [label = 'transportdata.gms']
B1 [label = '@@2']
C [label = 'stockflow.gms']
A -> B
B -> B1
B -> C
B1 -> C
}

[1]: paste0('Original Data (in Excel-File):\\n ','px-x-1103020100_102\\n px- x-1103020100_103\\n px-x-1103020100_105')
[2]: paste0('./temp/priv_carsdata.gdx')

")

Any help would be welcome!

Renger

like image 861
arnyeinstein Avatar asked Oct 17 '22 08:10

arnyeinstein


1 Answers

You can use hexadecimal colors for color. These are represented using a red-green-blue (RGB) triple; three hexadecimal numbers between 00 and FF, preceded by the character ’#’ (#rrggbb).
The alpha parameter (i.e. tranparency) can be defined simply adding two more hexadecimal digits, in the form #rrggbbaa. More details are given here.
In the following example we specify red color with alpha of 64 (i.e. 100 as decimal number).

grViz("
digraph  {
node [fontname = Helvetica, 
    shape = rectangle,  width = 3,
    color = '#FF000064', 
    style = filled 
    ]

edge [color = red,  arrowtail = none]

A [width = 3, label = '@@1']
B [label = 'transportdata.gms']
B1 [label = '@@2']
C [label = 'stockflow.gms']
A -> B
B -> B1
B -> C
B1 -> C
}
[1]: paste0('Original Data (in Excel-File):\\n ','px-x-1103020100_102\\n px- x-1103020100_103\\n px-x-1103020100_105')
[2]: paste0('./temp/priv_carsdata.gdx')
")

enter image description here

like image 70
Marco Sandri Avatar answered Oct 21 '22 03:10

Marco Sandri