java drawing graphs or trees in console

14,886

Solution 1

For people coming here looking for a pure Java tree drawing library: I recommend text-tree, which draws trees like this (and other styles, a lot of possible config if you need it):

some text
├─── more text
├─── and more
│    ├─── still more
│    ╰─── more
╰─── the end

Full disclosure: I am the author of text-tree.

Solution 2

You can print ascii trees with minimal code. See the second answer to this question: How to print binary tree diagram?

(the second answer because this one is not only for binary trees)

Solution 3

If I remember well, you can draw ascii graphs with javaplot

Share:
14,886
Benj
Author by

Benj

Java experimented dev, really loving all kinds of DIY after a long cogitation. Wait... isn't dev about connecting generic things with abstract bolts and virtual wires ?

Updated on July 25, 2022

Comments

  • Benj
    Benj almost 2 years

    Does anyone know a mean to "render" plots or at least trees in console mode (draw it in the console)?

    I would be able to render small plots at end of a very long process, by drawing some figures in ASCII mode, in order to have a geeky & fun view of some stats collected into the process.

    I would be pleased to discover a library which does that, and I would keep the process 100% java, no shell-hack or third-party software.

    -- EDIT

    @lbalazscs and @Fortega made interesting answers, but the background of my question is to know if it exists such a library, and I will add some details I missed the first time :

    The output should be able to display trees, binary trees (linked by @lbalazscs here), but also simple graphs such as bargraphs or so.

    I will let this question "unanswered" for a while, and if there is no probant answer, @lbalazscs will get the point ;)

  • Benj
    Benj over 11 years
    Ow Yeah ! Thanks for this interesting post !
  • Benj
    Benj over 11 years
    Thanks for the tip, however it requires to have third-party sofware installed (GNUPlot), which I would avoid to deal with. However, +1 for making me discover this cool lib, which I will use elsewhere.