Skip to content

Color ordering for single points in a Bloch sphere #2681

@marcogobbo

Description

@marcogobbo

Bug Description

If you use a list of colors (i.e., colormaps), the add_points() method weirdly orders colors.

Image

Code to Reproduce the Bug

from qutip import Bloch

x = [1, 0.5, 0, -0.5, -1]
y = [0, 0, 0, 0, 0]
z = [0, 0, 0, 0, 0]

b = Bloch()
b.point_color=list(['red', 'orange', 'yellow', 'cyan', 'blue'])
b.add_points([
    x,
    y,
    z
])
b.show()

Code Output

Expected Behaviour

Image

Your Environment

QuTiP Version:      5.1.1
Numpy Version:      2.2.4
Scipy Version:      1.15.2
Cython Version:     None
Matplotlib Version: 3.10.1
Python Version:     3.12.10
Number of CPUs:     32
BLAS Info:          Generic
INTEL MKL Ext:      None
Platform Info:      Windows (AMD64)

Additional Context

My temporary solution is to remove [indperm] from these lines, but I don't know if I broke other parts of the code, so I didn't open a PR to solve this issue.

qutip/qutip/bloch.py

Lines 869 to 879 in 4033695

if style in ['s', 'm']:
self.axes.scatter(np.real(points[1][indperm]),
-np.real(points[0][indperm]),
np.real(points[2][indperm]),
s=s,
marker=marker,
color=color,
alpha=self.point_alpha[k],
edgecolor=None,
zdir='z',
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions