from qiskit import *
%matplotlib inline
import numpy as np

qc = QuantumCircuit(2,2)
qc.h(0)
qc.cx(0,1)
qc.measure([0,1],[0,1])
qc.draw(output='mpl')

backend = Aer.get_backend('qasm_simulator')
result = execute(qc,backend).result()

from qiskit.tools.visualization import plot_histogram

plot_histogram(result.get_counts(qc))

counts = result.get_counts(qc)
legenda = ['Meu resultado']
plot_histogram(counts,color='red' ,legend=legenda)

IBMQ.load_account()
provedor = IBMQ.get_provider('ibm-q')
backend = provedor.get_backend('ibmq_valencia')

job = execute(qc,backend)

from qiskit.tools.monitor import job_monitor

job_monitor(job)

result2 = job.result()
counts2 = result2.get_counts(qc)
legenda = ['Simulador','CQ Real']

plot_histogram([counts,counts2],color=['red','green'] ,legend=legenda)

qc2 = QuantumCircuit(2,2)
qc2.h(0)
qc2.cx(0,1)

backend_st = Aer.get_backend('statevector_simulator')
result3 = execute(qc2, backend_st).result()
statevector = result3.get_statevector()

from qiskit.tools.visualization import plot_state_city

plot_state_city(statevector)

from qiskit.tools.visualization import plot_state_paulivec

plot_state_paulivec(statevector)

from qiskit.tools.visualization import plot_state_hinton

plot_state_hinton(statevector)

from qiskit.tools.visualization import plot_bloch_multivector

plot_bloch_multivector(statevector)

%matplotlib notebook 
# Repare que não está escrito inline como geralmente

plot_bloch_multivector(statevector)

# Para voltar ao normal é necessário apenas rodar o comando original

%matplotlib inline

from qiskit.tools.visualization import plot_bloch_vector
plot_bloch_vector([1,0,0])