What is plot()?
Flow.plot(filename='flow_diagram') writes an HTML file showing the method graph: starts, listeners, routers, and the and_/or_ relationships between them. Invaluable for debugging non-trivial flows.
Use Cases
- • Documentation
- • Debugging
- • Architectural review
Key Features
- ✓ Static visualization
- ✓ No runtime overhead during a real run
When NOT to Use
In production hot paths.
Notes
Stale diagrams in docs
Regenerate plot output in the same CI job that lints your Flow module so PR reviewers never trust an HTML file older than the code it claims to describe.
Dynamic listeners
Reflection captures declared methods, not runtime-only wiring. If you build listeners programmatically, the plot may under-report — document those paths manually.
Filesystem permissions
Serverless handlers often lack writable cwd. Pass an absolute filename under /tmp or a mounted volume.
Combinator literacy
When reviewers misread and_ vs or_, annotate the HTML commit message with the intended fan-in/fan-out behavior so graph edges map to business language.
Parameters
| Parameter | Type | Required | Purpose |
|---|---|---|---|
| filename | str | No | Base name for the output HTML. |
Code Examples
Render
flow.plot('my_flow')
CI artifact
from pathlib import Path
out = Path('artifacts') / 'onboarding_flow'
out.parent.mkdir(parents=True, exist_ok=True)
OnboardingFlow().plot(str(out))
When to Use
Debugging, documentation, sharing flow shape with reviewers.
Common Mistakes
❌ Trying to view the diagram during kickoff
✅ Call plot() separately, before/after kickoff.
Related: @tool decorator reference, Agent class reference, and the first Crew tutorial.
plot() FAQ
What is plot() in CrewAI?
Renders a visual diagram of the flow's @start / @listen / @router topology. Flow.plot(filename='flow_diagram') writes an HTML file showing the method graph: starts, listeners, routers, and the and_/or_ relationships between them. Invaluable for debugging non-trivial flows.
Which CrewAI types expose the method plot()?
DevShelfHub documents plot() on Flow. The reference maps it to Python module crewai.flow.flow.Flow — pin your installed crewai version and match imports to the snippet on this page.
When should I use plot()?
Debugging, documentation, sharing flow shape with reviewers.
When should I avoid plot()?
In production hot paths.
How do I call plot() from Python?
flow.plot('my_flow')
Where can I explore more CrewAI API reference pages?
Open the CrewAI API reference index on DevShelfHub to search classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.