import numpy as np
from qiskit import *

q = QuantumRegister(1)

# Create a Quantum Circuit acting on a quantum register of n qubits
qc = QuantumCircuit(q)

diag = qc.draw(output="mpl")
diag.savefig("1.png", format="png")


qc.h(0)
diag = qc.draw(output="mpl")
diag.savefig("2.png", format="png")

qc.z(0)
diag = qc.draw(output="mpl")
diag.savefig("3.png", format="png")

qc.h(0)
diag = qc.draw(output="mpl")
diag.savefig("4.png", format="png")


#Cropping images
!pip3 install Pillow
crp = [0,7,17,25]
from PIL import Image
for i in range(1,5):
    image = Image.open(str(i)+".png")
    w,h = image.size
    image.crop((20+crp[i-1],20,w,h-20)).save(str(i)+"c.png")

qc.measure(0,0)
qc.draw()

from qiskit.visualization import plot_bloch_vector

plot_bloch_vector([0,0,1], title='Intial state')


plot_bloch_vector([1,0,0], title='H gate')


plot_bloch_vector([-1,0,0], title='Z gate')

plot_bloch_vector([0,0,-1], title='H gate')



