3
$\begingroup$

How can I plot custom labels for specific qubits on the left and right side similar to the picture shown here (A, B, Sum ...):

$\endgroup$
1

1 Answer 1

3
$\begingroup$

A partial answer.

How to customize the labels of QuantumRegisters:

from qiskit import *

red_qubit = QuantumRegister(1,'red')
blue_qubit = QuantumRegister(1, 'blue')
green_qubit = QuantumRegister(2, 'green')

circuit = QuantumCircuit(red_qubit, blue_qubit, green_qubit)

circuit.h(red_qubit[0])
circuit.x(blue_qubit[0])
circuit.x(green_qubit[0])
circuit.cx(red_qubit[0], blue_qubit[0])
circuit.cx(red_qubit[0], green_qubit[0])
circuit.cx(red_qubit[0], green_qubit[1])

%matplotlib inline
circuit.draw(output="mpl")

The output:

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.