1

I am using QuTiP for the Bloch sphere plotting in Python. If I have several points on the Bloch sphere then I can connect them with a line using the command

b.add_points(pnts,meth='l')|

I wanted to know how can I change the linewidth of the line connecting these points.

James Parsons
  • 6,097
  • 12
  • 68
  • 108
Parveen
  • 29
  • 2

1 Answers1

1

There isn't a direct way to do this, since by default no linewidth parameter is passed while making this plot, but you can always plot the lines manually. The points need to be passed in as a list of numpy.ndarray objects.

The only catch is that to be consistent with what the Bloch class does, you need to make sure that the convention you are using to define the points is the same. It seems like the l method will only plot an connect the first three points that you feed in.

The following script reproduces this behaviour using a function that is similar to the one defined in Bloch:

import matplotlib.pyplot as plt
import qutip
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

pts = [np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]])]

fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection='3d'))
ax.axis('square') 

b = qutip.Bloch(fig=fig, axes=ax)

for p in pts:    
    b.axes.plot(p[1], -p[0], p[2],
                alpha=1, zdir='z', color='r', 
                linewidth=5) 

b.render(fig=fig, axes=ax)
plt.show()

The output figure is here:

enter image description here

krm
  • 847
  • 8
  • 13