Open dhruvbhq opened 4 years ago
I would assume this would require a change to plot_bloch_vector
(which plot_bloch_multivector
calls) to have support for multiple vectors instead of a single one. Should be a simple change in parameters to accept a list[list[double]], and a parameter in plot_bloch_multivector
to run a separate piece of code and pass all bloch_data
to plot_bloch_vector
.
Though a concern is how to differentiate the vectors, I believe there are only 5 colours and I'm not sure there is a way to label the vectors with a name currently.
:white_check_mark: Issue reproducible! It would be a great learning and visualisation tool if something like this could be added! OP can correct me if this is wrong but here is what may be expected!
Colour coding maybe required to be specified for standardization but it can be great to show visualisations of how state evolves!
Example implementation used as a learning tool - https://gitlab.com/qworld/silver
Will update comment/add more comments if cause is found/fixed!
Python version 3.9.7 qiskit-terra version: 0.19.1
Hi, If no one is working on this issue, can I take it? I have some experience with visualization and have contributed to Qiskit before, so have a little headstart. The major problem one could face is differentiating array-of-arrays from density matrices. Also, since no working solution is live on Qiskit, I'm assuming that this PR does not solve the issue.
As a workaround, this can be done easily using the Sphere class:
bloch_states = {
"|0⟩": [0, 0, 1],
"|1⟩": [0, 0, -1],
"|+⟩": [1, 0, 0],
"|-⟩": [-1, 0, 0],
"|i+⟩": [0, 1, 0],
"|i-⟩": [0, -1, 0]
}
from qiskit.visualization.bloch import Bloch
def plot_bloch_multiple_vector(bloch_data, title='Bloch Sphere', font_size=16):
fig, ax = plt.subplots(subplot_kw=dict(projection="3d"))
B = Bloch(axes=ax, font_size=font_size)
B.zlabel = ['z', '']
for key, value in bloch_data.items():
B.add_vectors([value])
B.add_annotation(value, key)
B.render(title=title)
return fig
I am fine if people work on the issue, maybe just check with the maintainers of the code once to get the go-ahead.
Can I take this issue?
What is the expected enhancement?
Using plot_bloch_multivector , to be able to plot multiple statevectors on the same Bloch sphere for easy comparison of change in state.