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

Plot_hinton imaginary section displays incorrect elements #8324

Closed
dimple12M opened this issue Jul 12, 2022 · 3 comments · Fixed by #8447
Closed

Plot_hinton imaginary section displays incorrect elements #8324

dimple12M opened this issue Jul 12, 2022 · 3 comments · Fixed by #8447
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@dimple12M
Copy link

Environment

  • Qiskit Terra version: 0.19.1
  • Python version: 3.7.9
  • Operating system: ios

Screenshot 2022-07-12 at 11 09 39 AM

What is happening?

In the Visualization section: plot_hinton
It displays 2 plots : one for real and one for imaginary
There are 2 issues:

  1. The imaginary elements displays the elements incorrect for real and negative numbers.
  2. The size of the square of the elements are not equal for the imaginary plot

How can we reproduce the issue?

Screenshot 2022-07-12 at 11 07 33 AM

What should happen?

We expect the following plot_hinton

Screenshot 2022-07-12 at 11 12 22 AM

Any suggestions?

We make few simple changes in the state_visualizaton.py file and we can obtain the correct plot for the imaginary section in the plot_hinton.

@HuangJunye
Copy link
Collaborator

The second part of this issue (The size of the square of the elements are not equal for the imaginary plot) will be fixed by #8447.

I am investigating in the first part of the issue. The hinton plot currently plots the matrix transversely. I am not sure if this is the expected behavior.

from qiskit.quantum_info import DensityMatrix
from qiskit.tools.visualization import plot_state_hinton

state = DensityMatrix(
    [
        [1,1],
        [-1,-0.5] 
    ])
plot_state_hinton(state)

produces

image

@dimple12M
Copy link
Author

The first part of the issue I think its related with the elements displayed on the hinton plot
As seen from the density matrix, the elements of the real part is displayed as shown :

from qiskit import QuantumCircuit
from qiskit.quantum_info import DensityMatrix
from qiskit.visualization import plot_state_hinton

qc = QuantumCircuit(2)
qc.h(0)

state = DensityMatrix.from_instruction(qc)
print(state)

Screenshot 2022-08-10 at 3 55 35 PM

@dimple12M
Copy link
Author

dimple12M commented Aug 10, 2022

This the second example specific : elements related to real as well as imaginary section.
I think, how are the elements are displaced is confusing . Still will look into it. Maybe we have can small description for the same.


from qiskit import QuantumCircuit
from qiskit.quantum_info import DensityMatrix
from qiskit.visualization import plot_state_hinton
![Screenshot 2022-08-10 at 4 10 46 PM](https://user-images.githubusercontent.com/65215560/183850058-45173b26-bbb1-4fa4-8186-e534dd6b726f.png)

state=DensityMatrix([[0.5+0.j, 0.+0.j, 0. -0.5j, 0. +0.j],
               [0.5+0.j, 0.+0.j, 0. -0.5j, 0. +0.j],
               [0.5 +0.j, 0. +0.j, 0. -0.5j, 0.+ 0.j],
               [0.5 +0.j, 0. +0.j, 0. -0.5j, 0. +0.j]])
                    
                    
plot_state_hinton(state)

Screenshot 2022-08-10 at 4 14 49 PM

@javabster javabster moved this to Tagged but unassigned in Contributor Monitoring Aug 16, 2022
@HuangJunye HuangJunye moved this from Tagged but unassigned to PR open / Contributor working on it in Contributor Monitoring Aug 18, 2022
@mergify mergify bot closed this as completed in #8447 Oct 19, 2022
Repository owner moved this from PR open / Contributor working on it to Done in Contributor Monitoring Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Done
3 participants