admin管理员组

文章数量:1122832

so I've ben playing around with Qiskit recently and have had success not only logging into the IBM machines but also executing circuits on their backends. I recently tried to plot the gate_map and error_map of each backend, but when I try to do so the plots are just empty in my juypter notebook e.g.

Am I missing something here? Are you unable to plot these things for their machines now? I'm seeing several references online that seem to indicate that you can somehow. Does anyone have any tips how I can get this plotting working? My code is below. Thank you for the help in advance!

from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit.visualization import plot_gate_map, plot_error_map
import matplotlib.pyplot as plt

# Read the API token from the file.
with open('ibm_quantum_token.txt', 'r') as token_file:
    api_token = token_file.read().strip()

# Save the token to your Qiskit account configuration.

 
QiskitRuntimeService.save_account(channel="ibm_quantum", token=api_token, set_as_default=True, overwrite=True)
 
# Load saved credentials
service = QiskitRuntimeService()
print("Account loaded successfully!")


from qiskit.visualization import plot_gate_map, plot_error_map
import matplotlib.pyplot as plt

backends = service.backends()

print("Available backends:")
for backend in backends:
    # Print the name of each backend.
    print(backend)
    fig_gate_map = plt.figure(figsize=(8, 6))
    plot_gate_map(backend)
    plt.title(f"Gate Map of {backend.name}", fontsize=16)
    plt.show()
    fig_error_map = plt.figure(figsize=(8, 6))
    plot_error_map(backend)
    plt.title(f"Gate Error of {backend.name}", fontsize=16)
    plt.savefig("gate_error:"+ str(backend.name) + str(".pdf"))
    plt.show()

本文标签: