2
$\begingroup$

I am trying to represent a quantum circuit schematically with some operators in QISKIT. I know I can create some operator with Operator() in quantum_info from a circuit circ like

Q1=quantum_info.Operator(circ)

To add the $Q_1$ operator to the circuit I can do

circ.append(Q1, [0, 1])

which adds $Q_1$ operator to the circuit and maps the 0th bit of the circuit to the 0th bit of the $Q_1$ operator and 1st bit of the circuit to the 1st bit of the $Q_1$ operator. The resulting circuit for a 4-qubit circuit circ is

enter image description here

I was wondering how to edit the label of the operator. Right now it's just showing Unitary in the circuit block. I tried to find this in the QISKIT documentation. So far, no luck!

$\endgroup$

1 Answer 1

1
$\begingroup$

One way to do that is to use QuantumCircuit.unitary method as follows

circ.unitary(Q1, [0, 1], 'Custom Label')

enter image description here

$\endgroup$
1
  • $\begingroup$ This is exactly what I needed, thank you. So it seems the operator method does not have similar flexibility then, we need to resort to the Unitary method. $\endgroup$
    – Anyon
    Jan 18, 2022 at 22:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.