2
$\begingroup$

This is the official demo(https://nbviewer.ipython.org/github/qutip/qutip-notebooks/blob/master/examples/visualization-exposition.ipynb). But after I run it, there is no error, but I can't output the graph of the Bloch sphere. This does not match the case. In addition, use display(b.b.make_sphere()) to return None. Something magical happened, what a beautiful day.

%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from qutip import *

H = sigmaz() + 0.3 * sigmay()
e_ops = [sigmax(), sigmay(), sigmaz()]
times = np.linspace(0, 10, 100)
psi0 = (basis(2, 0) + basis(2, 1)).unit()
result = mesolve(H, psi0, times, [], e_ops)
plot_expectation_values(result)
b = Bloch()
b.add_vectors(expect(H.unit(), e_ops))
b.add_points(result.expect, meth='l')
b.make_sphere()

my output:

enter image description here

demo's output:

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

you need to add b.show() to show the bloch
,maybe %matplotlib inline not working, you can try %matplotlib nbagg or %matplotlib notebook
read more about show: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.show.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.