I've been trying to plot the state $\frac{|0>-|1>}{\sqrt{2}}$ using Qiskit. As a result, I need to apply the NOT gate on $|0>$ to get $|1>$ and then apply the Hadamard gate on $|1>$ to get the required state. Here's my code -
from qiskit import QuantumCircuit, Aer, execute
from qiskit.visualization import plot_bloch_vector
import numpy as np
# Create a quantum circuit with one qubit
qc = QuantumCircuit(1)
# Apply a Hadamard gate to the |1> state
qc.x(0) # Apply an X gate to get |1>
qc.h(0) # Apply a Hadamard gate
# Simulate the circuit on the local qasm simulator
backend = Aer.get_backend('statevector_simulator')
job = execute(qc, backend)
result = job.result()
statevector = result.get_statevector()
# Extract the Bloch vector components from the state vector
bloch_vector = [2 * np.real(statevector[0]), 2 * np.imag(statevector[1]), 0]
# Plot the Bloch vector on the Bloch sphere
plot_bloch_vector(bloch_vector).show()
This image corresponds to the state $\frac{|0>+|1>}{\sqrt{2}}$. Can someone point out the not-so-obvious mistake in my code that I've failed to debug so far?