Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

pass_manager_drawer

pass_manager_drawer(pass_manager, filename=None, style=None, raw=False) GitHub(opens in a new tab)

Draws the pass manager.

This function needs pydot <https://github.com/erocarrera/pydot(opens in a new tab)>, which in turn needs Graphviz <https://www.graphviz.org/(opens in a new tab)>` to be installed.

Parameters

  • pass_manager (PassManager) – the pass manager to be drawn
  • filename (str) – file path to save image to
  • style (dict or OrderedDict) – keys are the pass classes and the values are the colors to make them. An example can be seen in the DEFAULT_STYLE. An ordered dict can be used to ensure a priority coloring when pass falls into multiple categories. Any values not included in the provided dict will be filled in from the default dict
  • raw (Bool) – True if you want to save the raw Dot output not an image. The default is False.

Returns

an in-memory representation of the pass manager. Or None if no image was generated or PIL is not installed.

Return type

PIL.Image or None

Raises

  • ImportError – when nxpd or pydot not installed.
  • VisualizationError – If raw=True and filename=None.

Example

 %matplotlib inline
from qiskit import QuantumCircuit
from qiskit.compiler import transpile
from qiskit.transpiler import PassManager
from qiskit.visualization import pass_manager_drawer
from qiskit.transpiler.passes import Unroller
 
circ = QuantumCircuit(3)
circ.ccx(0, 1, 2)
circ.draw()
 
pass_ = Unroller(['u1', 'u2', 'u3', 'cx'])
pm = PassManager(pass_)
new_circ = pm.run(circ)
new_circ.draw(output='mpl')
 
pass_manager_drawer(pm, "passmanager.jpg")
Was this page helpful?