Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to include colours to Bloch vectors instead of just cycling from a list #1292

Closed
quantshah opened this issue Jun 17, 2020 · 2 comments

Comments

@quantshah
Copy link
Member

quantshah commented Jun 17, 2020

The Bloch sphere is an amazing tool for visualisations. In a project where I wanted to show the evolution of an initial quantum state to a final target, I wanted to put specific colours to the initial and final bloch vector.

Right now, the function [qutip.bloch.add_states](https://github.com/qutip/qutip/blob/master/qutip/bloch.py#L353) or [qutip.bloch.add_vectors](https://github.com/qutip/qutip/blob/master/qutip/bloch.py#L378) cycles through a fixed list of colours here - https://github.com/qutip/qutip/blob/master/qutip/bloch.py#L563

It would be nice if the user could also add an optional color argument or list of colours when adding a new vector such as bloch.add_vectors(vec, color="r") or bloch.add_vectors([vec1, vec2], color=["red", "green"])

In this case I would have liked to set the two colours in the vector myself.

image

@rajathshetty20
Copy link

Hey, I tired solving this issue. I changed the add_vectors method such that it takes in an optional argument called 'color'. I created a dictionary called vector_color_specified which stores the vector-index and color as key-value pair. Then when plot_vectors is called, the color is taken from the dictionary if mentioned, otherwise the default value is used based on the cyclic color list which is already present. I tested my code and it works as you have mentioned above. So, is my approach right? Any advice would be helpful. This is the first open-source issue that I have taken up.

@BoxiLi
Copy link
Member

BoxiLi commented Jul 8, 2020

Hi @rajathshetty20, Thanks for the interest. What you described sounds good. Would you like to make a Pull Request? You can go to the Pull Requests page and create one from a branch of your repository. There will be a template guiding you once you choose a branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants