Home > OS >  DiagrammeR How to change plot background
DiagrammeR How to change plot background

Time:05-26

folowing code produces an simple diagram, how can I change background of whole graph to red, but keep background of nodes to B30668?

grViz(
  diagram = 
    "digraph flowchart {
        # define node aesthetics
        graph [fillcolor = red]
        node [fontname = Helvetica, shape = rectangle, fontcolor = black, arrowhead = none]        
      
      
        tab1 [label = '@@1', style = filled, fillcolor = '#B30668']
        tab2 [label = '@@2', style = filled, fillcolor = '#B30668']
        
        # set up node layout
        tab1 -> tab2;
        
        }
        
        [1]: 'a'
        [2]: 'b'

        ")

CodePudding user response:

You can use bgcolor to set a background in DiagrammeR like this:

library(DiagrammeR)
grViz(
  diagram = 
    "digraph flowchart {
        # define node aesthetics
        graph [fillcolor = red]
        node [fontname = Helvetica, shape = rectangle, fontcolor = black, arrowhead = none]
        bgcolor = red
      
      
        tab1 [label = '@@1', style = filled, fillcolor = '#B30668']
        tab2 [label = '@@2', style = filled, fillcolor = '#B30668']
        
        # set up node layout
        tab1 -> tab2;
        
        }
        
        [1]: 'a'
        [2]: 'b'

        ")

Output:

enter image description here

  •  Tags:  
  • r
  • Related