Search code examples
plantuml

Plantuml class diagram with multiple children: Any way to bifurcate the arrow?


My attempt:

Animal <|-- Cat
Animal <|-- Dog

Result:

  ┌────────┐
  │ Animal │
  └────────┘
   Δ      Δ
   │      │
┌──┴──┐┌──┴──┐
│ Cat ││ Dog │
└─────┘└─────┘

That is not how a class diagram is supposed to look like.

This is:

  ┌────────┐
  │ Animal │
  └────────┘
      Δ
   ┌──┴───┐
┌──┴──┐┌──┴──┐
│ Cat ││ Dog │
└─────┘└─────┘

As suggested, I asked if this is possible on the PlantUML forum.


Solution

  • You can do something like this:

    @startuml
    class Animal
    together {
      class Dog
      class Cat
    }
    Animal <|-- Cat
    Dog -- (Animal, Cat)
    @enduml
    

    result