Diagrams

Diagrams

  • Docs
  • Guides
  • GitHub

›Guides

Getting Started

  • Installation
  • Examples

Guides

  • Diagrams
  • Nodes
  • Clusters

Diagrams

Diagram is a primary object representing a diagram.

Basic

Diagram represents a global diagram context.

You can create a diagram context with Diagram class. The first parameter of Diagram constructor will be used for output filename.

from diagrams import Diagram
from diagrams.aws.compute import EC2

with Diagram("Simple Diagram"):
    EC2("web")

And if you run the above script with below command,

$ python diagram.py

It will generate an image file with single EC2 node drawn as simple_diagram.png on your working directory, and open that created image file immediately.

Options

You can specify the output file format with outformat parameter. Default is png.

(png, jpg, svg, and pdf) are allowed.

from diagrams import Diagram
from diagrams.aws.compute import EC2

with Diagram("Simple Diagram", outformat="jpg"):
    EC2("web")

You can also disable the automatic file opening by setting the show parameter as false. Default is true.

from diagrams import Diagram
from diagrams.aws.compute import EC2

with Diagram("Simple Diagram", show=False):
    EC2("web")
Last updated on 2020-2-3
← ExamplesNodes →
  • Basic
  • Options
Diagrams
Docs
Getting StartedGuides
More
GitHubStar
Copyright © 2020 mingrammer