Heatmaps

Qubit heatmaps are useful to visualize various different types of metrics across qubits. Cirq currently supports single qubit heatmaps and two-qubit interaction heatmaps for GridQubits.

View on QuantumAI Run in Google Colab View source on GitHub Download notebook
try:
    import cirq
except ImportError:
    print("installing cirq...")
    !pip install --quiet cirq
    print("installed cirq.")
    import cirq

Heatmaps for Custom Data

You can directly create heatmaps using custom data mapping from a grid qubit tuple (single qubit or qubit pair) to a corresponding float value. Additional config parameters for the heatmap can be passed as kwargs to the constructor. For example:

cirq.Heatmap({
    (cirq.GridQubit(0, 0),): 0.1,
    (cirq.GridQubit(0, 1),): 0.2,
    (cirq.GridQubit(0, 2),): 0.3,
    (cirq.GridQubit(1, 0),): 0.4,
}, plot_colorbar = False).plot()
(<AxesSubplot:xlabel='column', ylabel='row'>,
 <matplotlib.collections.PolyCollection at 0x7fde11060390>)

png

cirq.TwoQubitInteractionHeatmap({
    (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)): 1.1,
    (cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)): 1.4,
    (cirq.GridQubit(1, 0), cirq.GridQubit(0, 0)): 1.6,
    (cirq.GridQubit(3, 3), cirq.GridQubit(3, 2)): 1.9,
}, annotation_format="0.2f", title = 'Dummy Two Qubit Manual Plot').plot()
(<AxesSubplot:title={'center':'Dummy Two Qubit Manual Plot'}, xlabel='column', ylabel='row'>,
 <matplotlib.collections.PolyCollection at 0x7fde10fc7630>)

png