Repository: Qiskit/qiskit

Issue:
Make plot_state automatically convert state vectors to density matrices
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?

When calling the `plot_state` visualization function the input must be a density matrix, however the statevector simulator returns a state vector that must  be manually converted to a density matrix. This should be done automatically when a user calls `plot_state(statevector)`:

Expected use:

```python
import qiskit
from qiskit.tools.visualization import plot_state
qr = qiskit.QuantumRegister(2)
circ = qiskit.QuantumCircuit(qr)
circ.h(qr[0])
circ.cx(qr[0], qr[1])
result = qiskit.execute(circ, 'local_statevector_simulator).result()
state = result.get_statevector(circ)
fig = plot_state(state)
fig.show()
```


Discussion:

Resolving patch:
diff --git a/qiskit/tools/visualization/_state_visualization.py b/qiskit/tools/visualization/_state_visualization.py
--- a/qiskit/tools/visualization/_state_visualization.py
+++ b/qiskit/tools/visualization/_state_visualization.py
@@ -19,6 +19,7 @@
 from mpl_toolkits.mplot3d import proj3d
 import numpy as np
 from qiskit.tools.qi.pauli import pauli_group, pauli_singles
+from qiskit.tools.visualization import VisualizationError
 from qiskit.tools.visualization.bloch import Bloch
 
 
@@ -322,20 +323,32 @@ def plot_state_qsphere(rho):
             break
 
 
-def plot_state(rho, method='city'):
+def plot_state(quantum_state, method='city'):
     """Plot the quantum state.
 
     Args:
-        rho (ndarray): Density matrix representation
-            of a quantum state vector or mized state.
+        quantum_state (ndarray): statevector or density matrix
+                                 representation of a quantum state.
         method (str): Plotting method to use.
 
-    Note:
-        If input is a state vector, you must first
-        convert to density matrix via `qiskit.tools.qi.qi.outer`.
+    Raises:
+        VisualizationError: if the input is not a statevector or density
+        matrix, or if the state is not an multi-qubit quantum state.
     """
+
+    # Check if input is a statevector, and convert to density matrix
+    rho = np.array(quantum_state)
+    if rho.ndim == 1:
+        rho = np.outer(rho, np.conj(rho))
+    # Check the shape of the input is a square matrix
+    shape = np.shape(rho)
+    if len(shape) != 2 or shape[0] != shape[1]:
+        raise VisualizationError("Input is not a valid quantum state.")
+    # Check state is an n-qubit state
     num = int(np.log2(len(rho)))
-    # Need updating to check its a matrix
+    if 2 ** num != len(rho):
+        raise VisualizationError("Input is not a multi-qubit quantum state.")
+
     if method == 'city':
         plot_state_city(rho)
     elif method == "paulivec":
diff --git a/qiskit/tools/visualization/interactive/_iplot_state.py b/qiskit/tools/visualization/interactive/_iplot_state.py
--- a/qiskit/tools/visualization/interactive/_iplot_state.py
+++ b/qiskit/tools/visualization/interactive/_iplot_state.py
@@ -9,6 +9,8 @@
 QISKit visualization library.
 """
 
+import numpy as np
+from qiskit.tools.visualization import VisualizationError
 from ._iplot_blochsphere import iplot_blochsphere
 from ._iplot_cities import iplot_cities
 from ._iplot_hinton import iplot_hinton
@@ -16,21 +18,33 @@
 from ._iplot_qsphere import iplot_qsphere
 
 
-def iplot_state(rho, method='city', options=None):
+def iplot_state(quantum_state, method='city', options=None):
     """Plot the quantum state.
 
     Args:
-        rho (ndarray): Density matrix representation
-            of a quantum state vector or mized state.
+        quantum_state (ndarray): statevector or density matrix
+                                 representation of a quantum state.
         method (str): Plotting method to use.
         options (dict): Plotting settings.
 
-    Note:
-        If input is a state vector, you must first
-        convert to density matrix via `qiskit.tools.qi.qi.outer`.
+    Raises:
+        VisualizationError: if the input is not a statevector or density
+        matrix, or if the state is not an multi-qubit quantum state.
     """
 
-    # Need updating to check its a matrix
+    # Check if input is a statevector, and convert to density matrix
+    rho = np.array(quantum_state)
+    if rho.ndim == 1:
+        rho = np.outer(rho, np.conj(rho))
+    # Check the shape of the input is a square matrix
+    shape = np.shape(rho)
+    if len(shape) != 2 or shape[0] != shape[1]:
+        raise VisualizationError("Input is not a valid quantum state.")
+    # Check state is an n-qubit state
+    num = int(np.log2(len(rho)))
+    if 2 ** num != len(rho):
+        raise VisualizationError("Input is not a multi-qubit quantum state.")
+
     if method == "city":
         iplot_cities(rho, options)
     elif method == "paulivec":


Test patch: