3
$\begingroup$

Qiskit has a plot_coupling_map option for visualizing coupling maps however, I want to be able to use it from a CouplingMap object instead of the provided CouplingMap.draw() (which uses graphviz).

The plot_coupling_map requires num_qbits, qubit_coordinates and coupling_map. I see how I can get the num_qbits (CouplingMap.size()) and the coupling_map is just the CouplingMap, but I don't see an easy way to get the qubit_coords. Do I have to generate them each time I want to plot it?

$\endgroup$

1 Answer 1

1
$\begingroup$

Although it is not mentioned in the documentation, None is a valid value for qubit_coordinates. So, the below code snippet should work without any issue with Qiskit version 1.0

coupling_map = CouplingMap.from_grid(3, 3)
plot_coupling_map(
    coupling_map.size(),
    qubit_coordinates=None,
    coupling_map=coupling_map.get_edges()
)

The result:

enter image description here

$\endgroup$

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.