Drawing diagrams with PlantUML
Gantt Diagrams
You can use PlantUML instead of applications like Microsoft Project to make basic Gantt diagrams, with deadline and task dependencies. If you feed the code in Listing 2 to PlantUML, you will get a Gantt diagram like the one shown in Figure 2. While PlantUML diagrams are not as polished as Microsoft Project diagrams, the source code can be quickly written (even on your smartphone) in human-readable text. Gantt diagrams use their own beginning (line 1) and end (line 12) keywords. In addition, using scale
(line 2) makes the diagram four times bigger than PlantUML's default minimum size (note: this syntax does not work the same for all diagrams).
Listing 2
Gantt Diagram
01 @startgantt 02 scale 4 03 Project starts the 2020/03/02 04 [Prestudy] lasts 10 days and is colored in Lavender/LightBlue 05 [Milestone 1] happens at [Prestudy]'s end 06 [System simulation] lasts 9 days and is colored in Coral/Green and starts 1 day after [Prestudy]'s end 07 [Use cases def.] lasts 7 days and ends at [Prestudy]'s end 08 [Compliance\nspecs] lasts 3 days and ends at [Use cases def.]'s start 09 [Select testers] is colored in Coral/Green 10 [Select testers] lasts 5 days and starts at [Use cases def.]'s start 11 [Train testers] starts 1 days after [Milestone 1]'s end and lasts 7 days 12 @endgantt
![](/var/linux_magazin/storage/images/issues/2020/235/plantuml-diagrams/figure-2/767631-1-eng-US/Figure-2_large.png)
Mind Maps
Mind maps are an excellent way to represent the relationship between concepts or objects. To draw mind maps in PlantUML, you need to enclose all the mind map's elements between the keywords @startmindmap
and @endmindmap
, starting with the main element and indenting the following elements with asterisks or dashes. Figures 3 and 4 show two mind map layouts, with their respective source code in Listings 3 and 4. Functionally speaking, Figures 3 and 4 are identical, with the only differences being orientation and boxing. In Figure 4, the root element (Carnivores) is in the center, because using dashes (lines 6 to 9, Listing 4) instead of asterisks (lines 6 to 9, Listing 3) forces the whole Canides section to the left. The underscores in lines 7 to 9 in Listing 4 tell PlantUML to not draw boxes around those elements. In mind maps, you can also use basic HTML tags for formatting, such as the underline tag (line 6 in Listings 3 and 4) and the bold face tag (lines 10 and 13 in Listings 3 and 4).
Listing 3
Mind Map Diagram
01 @startmindmap 02 * Carnivores 03 ** Felines 04 *** Felis 05 *** Panthera 06 ** <u>Canides</u> 07 *** Canis 08 **** Familiaris 09 **** Lupus 10 ** <b>Ursides</b> 11 *** Ursus 12 **** Arctos 13 **** <b>Horribilus</b> 14 @endmindmap
Listing 4
Alternative Mind Map Diagram
01 @startmindmap 02 * Carnivores 03 ** Felines 04 *** Felis 05 *** Panthera 06 -- <u>Canides</u> 07 ---_ Canis 08 ----_ Familiaris 09 ----_ Lupus 10 ** <b>Ursides</b> 11 *** Ursus 12 **** Arctos 13 **** <b>Horribilus</b> 14 @endmindmap
![](/var/linux_magazin/storage/images/issues/2020/235/plantuml-diagrams/figure-4/767637-1-eng-US/Figure-4_large.png)
WBS Charts
PlantUML uses the Work Breakdown Structure (WBS) format for organizational charts. Figure 5 (source code shown in Listing 5) shows a company org chart, but you can use this type of diagram for other things, like a manufacturing process or a school syllabus.
Listing 5
WBS Diagram
01 @startwbs 02 + Board of Directors 03 ++ <u>Legal/Finance</u> 04 ++ <b>R&D</b> 05 +++ Software 06 ++++ Design 07 ++++ Testing 08 ++- Hardware 09 ++++ Digital Circuits 10 +++- PCB Boards 11 ++++ Analog Circuits 12 +++ System design 13 +++- Modeling 14 ++++ Simulation 15 ++ <b>Production</b> 16 ++- Procurement 17 +++ Manufacturing 18 ++++ Mechanics 19 ---- Electronics 20 @endwbs
![](/var/linux_magazin/storage/images/issues/2020/235/plantuml-diagrams/figure-5/767640-1-eng-US/Figure-5_large.png)
The biggest challenge with WBS diagrams in UML is balancing the diagram visually (avoiding empty areas alongside crowded areas). In general, you assign hierarchy with indentation. Visual balancing is achieved by changing the section order (when possible) and by using dashes instead of plus characters to change each box's orientation (Listing 5, lines 10, 13, 16, and 19). This syntax is compatible with Emacs' Org Mode. However, WBS diagrams are still a beta feature in PlantUML, so their look and feel, if not their syntax, may change in future versions.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.