Repository: Qiskit/qiskit

Issue:
Plot_hinton imaginary section displays incorrect  elements
### Environment

- **Qiskit Terra version**: 0.19.1
- **Python version**: 3.7.9
- **Operating system**: ios

![Screenshot 2022-07-12 at 11 09 39 AM](https://user-images.githubusercontent.com/65215560/178400511-31621abb-5fba-470a-a892-09491c30f29b.png)



### 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](https://user-images.githubusercontent.com/65215560/178400081-77179217-5273-433c-9c51-d1eed8db195b.png)


### What should happen?

We expect the following plot_hinton


![Screenshot 2022-07-12 at 11 12 22 AM](https://user-images.githubusercontent.com/65215560/178400621-fe67b631-040b-408e-9423-acfd764981fb.png)


### 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.


Discussion:

Resolving patch:
diff --git a/qiskit/visualization/state_visualization.py b/qiskit/visualization/state_visualization.py
--- a/qiskit/visualization/state_visualization.py
+++ b/qiskit/visualization/state_visualization.py
@@ -113,8 +113,9 @@ def plot_state_hinton(
             fig = ax_imag.get_figure()
         ax1 = ax_real
         ax2 = ax_imag
+    # Reversal is to account for Qiskit's endianness.
     column_names = [bin(i)[2:].zfill(num) for i in range(2**num)]
-    row_names = [bin(i)[2:].zfill(num) for i in range(2**num)]
+    row_names = [bin(i)[2:].zfill(num) for i in range(2**num)][::-1]
     ly, lx = datareal.shape
     # Real
     if ax1:
@@ -124,10 +125,12 @@ def plot_state_hinton(
         ax1.yaxis.set_major_locator(plt.NullLocator())
 
         for (x, y), w in np.ndenumerate(datareal):
+            # Convert from matrix co-ordinates to plot co-ordinates.
+            plot_x, plot_y = y, lx - x - 1
             color = "white" if w > 0 else "black"
             size = np.sqrt(np.abs(w) / max_weight)
             rect = plt.Rectangle(
-                [0.5 + x - size / 2, 0.5 + y - size / 2],
+                [0.5 + plot_x - size / 2, 0.5 + plot_y - size / 2],
                 size,
                 size,
                 facecolor=color,
@@ -138,10 +141,9 @@ def plot_state_hinton(
         ax1.set_xticks(0.5 + np.arange(lx))
         ax1.set_yticks(0.5 + np.arange(ly))
         ax1.set_xlim([0, lx])
-        ax1.set_ylim([ly, 0])
+        ax1.set_ylim([0, ly])
         ax1.set_yticklabels(row_names, fontsize=14)
         ax1.set_xticklabels(column_names, fontsize=14, rotation=90)
-        ax1.invert_yaxis()
         ax1.set_title("Re[$\\rho$]", fontsize=14)
     # Imaginary
     if ax2:
@@ -151,10 +153,12 @@ def plot_state_hinton(
         ax2.yaxis.set_major_locator(plt.NullLocator())
 
         for (x, y), w in np.ndenumerate(dataimag):
+            # Convert from matrix co-ordinates to plot co-ordinates.
+            plot_x, plot_y = y, lx - x - 1
             color = "white" if w > 0 else "black"
             size = np.sqrt(np.abs(w) / max_weight)
             rect = plt.Rectangle(
-                [0.5 + x - size / 2, 0.5 + y - size / 2],
+                [0.5 + plot_x - size / 2, 0.5 + plot_y - size / 2],
                 size,
                 size,
                 facecolor=color,
@@ -164,12 +168,12 @@ def plot_state_hinton(
 
         ax2.set_xticks(0.5 + np.arange(lx))
         ax2.set_yticks(0.5 + np.arange(ly))
-        ax1.set_xlim([0, lx])
-        ax1.set_ylim([ly, 0])
+        ax2.set_xlim([0, lx])
+        ax2.set_ylim([0, ly])
         ax2.set_yticklabels(row_names, fontsize=14)
         ax2.set_xticklabels(column_names, fontsize=14, rotation=90)
-        ax2.invert_yaxis()
         ax2.set_title("Im[$\\rho$]", fontsize=14)
+    fig.tight_layout()
     if title:
         fig.suptitle(title, fontsize=16)
     if ax_real is None and ax_imag is None:


Test patch: