Skip to main content
IBM Quantum Platform

qiskit.visualization.plot_circuit_layout

qiskit.visualization.plot_circuit_layout(circuit, backend, view='virtual', qubit_coordinates=None)

GitHub

Plot the layout of a circuit transpiled for a given target backend.

Deprecated since version 1.4

The function plot_circuit_layout will stop supporting inputs of type BackendV1 in the backend parameter in a future release no earlier than 2.0. BackendV1 is deprecated and implementations should move to BackendV2.

Parameters

  • circuit (QuantumCircuit) – Input quantum circuit.

  • backend (Backend) – Target backend.

  • view (str) –

    How to label qubits in the layout. Options:

    • "virtual": Label each qubit with the index of the virtual qubit that mapped to it.
    • "physical": Label each qubit with the index of the physical qubit that it corresponds to on the device.
  • qubit_coordinates (Sequence) – An optional sequence input (list or array being the most common) of 2d coordinates for each qubit. The length of the sequence must match the number of qubits on the backend. The sequence should be the planar coordinates in a 0-based square grid where each qubit is located.

Returns

A matplotlib figure showing layout.

Return type

Figure

Raises

Example

from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.visualization import plot_circuit_layout
 
ghz = QuantumCircuit(3, 3)
ghz.h(0)
for idx in range(1,3):
    ghz.cx(0,idx)
ghz.measure(range(3), range(3))
 
backend = GenericBackendV2(num_qubits=5)
new_circ_lv3 = transpile(ghz, backend=backend, optimization_level=3)
plot_circuit_layout(new_circ_lv3, backend)
Output from the previous code.
Was this page helpful?
Report a bug or request content on GitHub.