-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to save mpl image to file #108
Comments
If you are running from the command line (not on Jupyter Notebook), you can use the following program. from qulacs import QuantumCircuit
import matplotlib.pyplot as plt
from qulacsvis.visualization import MPLCircuitlDrawer # Use instead of circuit_drawer
# Build a your quantum circuit
circuit = QuantumCircuit(3)
circuit.add_X_gate(0)
circuit.add_Y_gate(1)
circuit.add_Z_gate(2)
circuit.add_dense_matrix_gate(
[0, 1], [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]
)
circuit.add_CNOT_gate(2, 0)
circuit.add_X_gate(2)
drawer = MPLCircuitlDrawer(circuit)
fig = drawer.draw()
plt.savefig("output.png") # save to file However, in many cases you will want to run it on Jupyter Notebook. This is apparently broken. Sorry. I am working on fixing this. |
Thanks - works great! |
Fixed. Upgrade qulacsvis to v0.7.0 and use it this way. circuit_drawer(circuit, "mpl", filename="output.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Nice library. Is there a way to save the mpl image to a file, rather than display it on screen?
Thanks
Evan
The text was updated successfully, but these errors were encountered: