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()
本文标签:
版权声明:本文标题:python - Why Are plot_gate_map and plot_error_map Showing Empty Plots in Jupyter Notebook with Qiskit? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283757a1927070.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论