1

I am trying to create a flowchart with 24 primary nodes and some other secondary nodes using GraphViz i.e. grViz().

I wish to increase the gap between the nodes to have a clear view. But it is reducing the font size of the labels in each node, though I have kept the fontsize = 200 for the label of each node. This is what I have done.

    library( DiagrammeR ) 

    DiagrammeR(diagram = "", type = "grViz")

    #.....Using GraphViz.....

    grViz("

          digraph dot {

          graph[layout = dot,
          rankdir = LR]

          #....adding node statement for 's_o' key....

          node[shape = circle, width = 20, style = filled, color = Black,           fontname = Arial, fontsize = 200, penwidth = 20]

          node[fillcolor = red]
          's_o'


          #....adding node statement for primary branching....
          #....defining the primary keys.....

          node[shape = box, width = 30, style = filled, color = Black, fontname = Arial, fontsize = 200, penwidth = 20]

          node[fillcolor = green]
          's_j'; 'f_s'; 'b_v'; 'o_c'; 'm_h'; 'a_v', 'o_o', 'm_u_ \nw_s'; 'p_u_ \n24_h'; 'b_d_ \nm'; 'm_u_ \ne_p_ \ns_p'; 's_s_p'; 's_s_p'; 'c_im_ \ns_p'; 'u_s_p'; 'v_im_ \ns_p'; 'd_f_ \ns_p'; 'm_b_f_ \n_p'; 'p_s_p'; 's_w_f_ \n_p'; 'ir_r_t_ \n10'; 'a_t_ \n10'; 'o_h_ \n24'


          #.....adding edge statement for primary statement....
          #.....mapping the main node with the primary nodes....

          edge[arrowhead = normal, arrowsize = 10,minlen = 6, style = bold, color = Black, headclip = TRUE, tailclip = TRUE]
          s_o -> {'s_j'; 'f_s'; 'b_v'; 'o_c'; 'm_h'; 'a_v', 'o_o', 'm_u_ \nw_s'; 'p_u_ \n24_h'; 'b_d_ \nm'; 'm_u_ \ne_p_ \ns_p'; 's_s_p'; 'c_im_ \ns_p'; 'u_s_p'; 'v_im_ \ns_p'; 'd_f_ \ns_p'; 'm_b_f_ \n_p'; 'p_s_p'; 's_w_f_ \n_p'; 'ir_r_t_ \n10'; 'a_t_ \n10'; 'o_h_ \n24'}


          #....adding node statement for secondary branching....

          #.....Defining the secondary keys for 's_j' key...

          node[shape = box, height = 5, width = 12, style = filled, color = Black, fontname = Arial, fontsize = 150, penwidth = 20]

          node[fillcolor = orange]
          '1 : \n j'; '2 : \n j'; '...' ; 


          #.....From 'f_s' key...

          node[shape = box, height = 5, width = 30, style = filled, color = Black, fontname = Arial, fontsize = 150, penwidth = 20]

          node[fillcolor = orange]
          't1 : \n 0 or c_t_v'; 'l_k_s_t'; 'h_ts'; 


          #.....From 'b_v' key...

          node[shape = box, height = 5, width = 30, style = filled,      color = Black, fontname = Arial, fontsize = 150, penwidth = 20]

          node[fillcolor = orange]
          't1 : \n 0 or c_t_v'; 'l_k_s_t'; 'h_ts'; 
          'b_ts'

          #.....adding edge statement for secondary statement....

          #.....From 's_j' key....

          edge[arrowhead = normal, arrowsize = 10,minlen = 6, style = bold, color = Black, headclip = TRUE, tailclip = TRUE]
          s_j -> {'1 : \n j'; '2 : \n j'; '...'}

          #.....From 'f_s' key....

          edge[arrowhead = normal, arrowsize = 10,minlen = 6, style = bold, color = Black, headclip = TRUE, tailclip = TRUE]
          f_s -> {'t1 : \n 0 or c_t_v'; 'l_k_s_t';
          'h_ts'}

          #.....From 'b_v' key....
          edge[arrowhead = normal, arrowsize = 10,minlen = 6, style = bold, color = Black, 
          headclip = TRUE, tailclip = TRUE]
          b_v -> {'t1 : \n 0 or c_t_v'; 'l_k_s_t'; 
          'h_ts'; 'b_ts'}

          #....adding a graph statement.....

          graph[nodesep = 2]

          }        

          ")

Output :

Output of this code

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
Ankita
  • 91
  • 1
  • 2
  • I guess this is because `htmlwidgets` has to squeeze the graph into a rather small browser window - the window source codes says ``. You may want to try to produce the graph with "real" graphviz. – vaettchen Nov 16 '17 at 13:26
  • Can you kindly explain what you meant by "real" graphviz? – Ankita Nov 17 '17 at 08:26
  • Ah sorry I thought that was obvious -- the `DiagrammeR` function is only a wrapper for [graphviz](http://www.graphviz.org) which does the work in the background. It gives you a variety of output options (png, pdf, svg...) without size constraints. You would need to edit your commands a bit and you can get rid of the strange font size. – vaettchen Nov 17 '17 at 08:30

0 Answers0