5

Here is the code for the graph I currently have:

graph Budget {
    Country_Budget -- Profit_and_Loss_Account  [type=s];
    Country_Budget -- Balance_Sheet [type=s];
     Profit_and_Loss_Account -- Income [type=s];
     Profit_and_Loss_Account -- Expenditure [type=s];
     Income -- Revenue_Income [type=s];
     Income -- Capital_Income [type=s];
     Expenditure -- Revenue_Expenditure [type=s];
     Expenditure -- Capital_Expenditure [type=s]; 
     Balance_Sheet -- Assets [type=s]; 
     Balance_Sheet -- Liabilities [type=s];
}

and here is the rendering when using dotty tool -

rough sketch of country budget

While it gives the details and the structure, does anybody know a way to make it more colorful?

Running graphviz 2.38.0-16 on Debian.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
shirish
  • 11,967
  • 27
  • 107
  • 190
  • I'm not convinced this is sufficiently opinion-based to be left closed. Although I accept that "beauty is in the eye of the beholder" (or whatever it is), the question is straightforward enough – roaima Aug 04 '20 at 18:07
  • “What would make this graph [more] beautiful?” would clearly be an opinion-based question, but “more colorful or something?” is too broad (lacking in detail).  Besides, a Google search of the title of this question yielded [Making pretty diagrams with GraphViz](https://steveliles.github.io/making_pretty_diagrams_with_graphviz.html), [graphviz 0.14.1 User Guide](https://graphviz.readthedocs.io/en/stable/manual.html) and [GraphViz Examples and Tutorial / GraphViz Pocket Reference](https://graphs.grevian.org/example) *on the first page of results,* suggesting that the OP hasn’t done any research. – G-Man Says 'Reinstate Monica' Aug 04 '20 at 19:40
  • If "Google gives you the answer on the first page" is criteria for a question being closed, there would be _myriad_ more closed questions here. If the question were altered to simply ask "How can I add color to a GraphViz graph?" would it still be opinion-based or unclear? – DopeGhoti Aug 04 '20 at 20:12
  • @DopeGhoti no, I think then it would no longer be opinion-based. Considering that the accepted answer is about adding color, this might even be in line with the author's original intention, so "edit and reopen" with changing the title in that way may be permissible. – AdminBee Aug 05 '20 at 07:53
  • I found this part of the documentation useful to add color to nodes: https://www.graphviz.org/doc/info/shapes.html – Gabriel Devillers Aug 09 '21 at 10:20

1 Answers1

5

You could do something like:

graph Budget {
   subgraph tier1 {
      node [color="lightgreen",style="filled",group="tier1"]
      Country_Budget
   }
   
   subgraph tier2 {
      node [color="green",style="filled",group="tier2"]
      Profit_and_Loss_Account
      Balance_Sheet
   }
   
   subgraph tier3 {
      node [color="lightblue",style="filled",group="tier3"]
      Income
      Expenditure
      Assets
      Liabilities
   }
   
   subgraph tier4 {
      node [color="yellow",style="filled",group="tier4"]
      Revenue_Income
      Capital_Income
      Revenue_Expenditure
      Capital_Expenditure
   }
   
   Country_Budget -- {Profit_and_Loss_Account Balance_Sheet}
   Profit_and_Loss_Account -- {Income Expenditure}
   Income -- {Revenue_Income Capital_Income}
   Expenditure -- {Revenue_Expenditure Capital_Expenditure}
   Balance_Sheet -- {Assets Liabilities}
}

Example Output

DopeGhoti
  • 73,792
  • 8
  • 97
  • 133