Change color of symbols in Bloch sphere

572 views
Skip to first unread message

aaa aaa

unread,
Sep 30, 2016, 2:22:59 PM9/30/16
to QuTiP: Quantum Toolbox in Python
I want to change color of symbols in Bloch sphere. 
There are official examples to do this thing as bellow link, but they don't work.

Concretely, I wrote bellow code as same as the examples.
from qutip import *
import numpy as np
from math import *

b = Bloch()
xp = [np.cos(th) for th in np.linspace(0, 2*pi, 20)]
yp = [sin(th) for th in np.linspace(0, 2*pi, 20)]
zp = np.zeros(20)
pnts = [xp, yp, zp]
b.add_points(pnts,'m') # <-- add a 'm' string to signify 'multi' colored points
b.show()
Usually, 'm' option in b.add_points(pnts,'m') works for multi color option, but it doesn't work with no error message. 
I also tried "b.add_points(pnts, meth='m')". 
Furthermore, I added points one by one by the command "b.add_points( )".
Usually, added points are shown in different color automatically as described in the examples.
But it also doesn't work with no error message.
However I can change color of vectors automatically as same as the examples.

How should I do?

I use qutip in follow conditions.
QuTiP Version:      3.1.0
Numpy Version:      1.11.1
Scipy Version:      0.18.0
Cython Version:     0.23.4
Matplotlib Version: 1.5.1
Fortran mcsolver:   False
scikits.umfpack:    False
Python Version:     2.7.12
Platform Info:      Windows (AMD64)
Installation path:  C:\Anaconda2\lib\site-packages\qutip

Paul Nation

unread,
Oct 2, 2016, 2:00:29 PM10/2/16
to QuTiP: Quantum Toolbox in Python
There are the 'point_color' and 'vector_color' properties.

aaa aaa

unread,
Oct 2, 2016, 5:11:00 PM10/2/16
to QuTiP: Quantum Toolbox in Python
Thank you for your answer. 
I know these properties. 
I think the 'point_color' property is correctly set because that when I tried 'print(b)' command, the output is 'point_color:     ['b', 'r', 'g', '#CC6600']'.
However the symbols are in same color blue, although shape of symbols are correctly changed. 
How should I do?

polly

unread,
Mar 17, 2017, 8:29:48 PM3/17/17
to QuTiP: Quantum Toolbox in Python
I have the same error as this.  Is this a bug that is still present?  thanks

Paul Nation

unread,
Mar 18, 2017, 10:37:42 AM3/18/17
to QuTiP Group
I will look into this tonight.

-P

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Nation

unread,
Mar 21, 2017, 11:44:28 PM3/21/17
to QuTiP: Quantum Toolbox in Python
I get the exact same plot as the documentation.  

multi_markers.png

polly

unread,
Apr 1, 2017, 11:02:13 PM4/1/17
to QuTiP: Quantum Toolbox in Python
thanks for your reply Paul.  Here is my code and output, showing that I don't get what you do:

from qutip import *
from scipy import * 
import numpy as np

b = Bloch()
b.clear()

xp = [np.cos(th) for th in np.linspace(0, 2*pi, 20)]
yp = [np.sin(th) for th in np.linspace(0, 2*pi, 20)]
zp = np.zeros(20)
pnts = [xp, yp, zp]
b.add_points(pnts,'m')
b.show()

....this code produces the attached figure.

I can also try to add two series of points, each series I would expect to have a different colour but they are both blue:

from qutip import *
from scipy import * 
import numpy as np

b = Bloch()
b.clear()

xp = [np.cos(th) for th in np.linspace(0, 2*pi, 20)]
yp = [np.sin(th) for th in np.linspace(0, 2*pi, 20)]
zp = np.zeros(20)
pnts = [xp, yp, zp]
b.add_points(pnts,'m')

xz = np.zeros(20)
yz = [np.sin(th) for th in np.linspace(0, pi, 20)]
zz = [np.cos(th) for th in np.linspace(0, pi, 20)]
pnts2 = [xz, yz, zz]
b.add_points(pnts2)

b.show()
bFig=b.fig
bFig.savefig('testFig2')

....which produces the second attached fig

Can you suggest any changes/things I should check?

Also, here is the result of print(b) showing that it should be cycling through colours

Bloch data:
-----------
Number of points:  2
Number of vectors: 0

Bloch sphere properties:
------------------------
font_color:      black
font_size:       20
frame_alpha:     0.2
frame_color:     gray
frame_width:     1
point_color:     ['b', 'r', 'g', '#CC6600']
point_marker:    ['o', 's', 'd', '^']
point_size:      [25, 32, 35, 45]
sphere_alpha:    0.2
sphere_color:    #FFDDDD
figsize:         [5, 5]
vector_color:    ['g', '#CC6600', 'b', 'r']
vector_width:    3
vector_style:    -|>
vector_mutation: 20
view:            [-60, 30]
xlabel:          ['$x$', '']
xlpos:           [1.2, -1.2]
ylabel:          ['$y$', '']
ylpos:           [1.2, -1.2]
zlabel:          ['$\\left|0\\right>$', '$\\left|1\\right>$']
zlpos:           [1.2, -1.2]

thanks!
testFig.png
testFig2.png

Paul Nation

unread,
Apr 3, 2017, 12:32:10 AM4/3/17
to qu...@googlegroups.com
I still can not reproduce your problem.  I get multicolored points when I run the code that you attached.

-P

April 1, 2017 at 21:02
--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
March 21, 2017 at 21:44
I get the exact same plot as the documentation.  

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
September 30, 2016 at 12:22
I want to change color of symbols in Bloch sphere. 
There are official examples to do this thing as bellow link, but they don't work.

Concretely, I wrote bellow code as same as the examples.
from qutip import *
import numpy as np
from math import *

b = Bloch()
xp = [np.cos(th) for th in np.linspace(0, 2*pi, 20)]
yp = [sin(th) for th in np.linspace(0, 2*pi, 20)]
zp = np.zeros(20)
pnts = [xp, yp, zp]
b.add_points(pnts,'m') # <-- add a 'm' string to signify 'multi' colored points
b.show()
Usually, 'm' option in b.add_points(pnts,'m') works for multi color option, but it doesn't work with no error message. 
I also tried "b.add_points(pnts, meth='m')". 
Furthermore, I added points one by one by the command "b.add_points( )".
Usually, added points are shown in different color automatically as described in the examples.
But it also doesn't work with no error message.
However I can change color of vectors automatically as same as the examples.

How should I do?

I use qutip in follow conditions.
QuTiP Version:      3.1.0
Numpy Version:      1.11.1
Scipy Version:      0.18.0
Cython Version:     0.23.4
Matplotlib Version: 1.5.1
Fortran mcsolver:   False
scikits.umfpack:    False
Python Version:     2.7.12
Platform Info:      Windows (AMD64)
Installation path:  C:\Anaconda2\lib\site-packages\qutip
--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

Alex Pitchford

unread,
Apr 3, 2017, 8:06:07 AM4/3/17
to qu...@googlegroups.com
Hi Polly,

I have not followed the thread all the way through, so apologies if you have already been through this, but I see you are using qutip 3.10. Is there any reason why you cannot upgrade to the latest 4.10?
Not saying that will fix this, but might be worth a try.

Alex

To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
March 21, 2017 at 21:44
I get the exact same plot as the documentation.  

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

MM

unread,
Mar 15, 2018, 11:59:11 PM3/15/18
to QuTiP: Quantum Toolbox in Python
Hi Alex,

 I'm using qutip 4.10 yet have the same problem. I'm using ubuntu.

best
MM
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
March 21, 2017 at 21:44
I get the exact same plot as the documentation.  

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

polly

unread,
Mar 16, 2018, 12:41:51 AM3/16/18
to QuTiP: Quantum Toolbox in Python
Recently I got around to upgrading from V3.  I found that the problem had been resolved in the newer version:

QuTiP: Quantum Toolbox in Python
Copyright (c) 2011 and later.
A. J. Pitchford, P. D. Nation, R. J. Johansson, A. Grimsmo, and C. Granade

QuTiP Version:      4.2.0
Numpy Version:      1.13.3
Scipy Version:      1.0.0
Cython Version:     0.27.3
Matplotlib Version: 2.2.0
Python Version:     3.6.4
Number of CPUs:     4
BLAS Info:          INTEL MKL
OPENMP Installed:   False
INTEL MKL Ext:      True
Platform Info:      Windows (AMD64)
Reply all
Reply to author
Forward
0 new messages