qiskit-documentation/docs/api/qiskit/0.29/qiskit.visualization.plot_b...

50 lines
1.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: plot_bloch_vector (v0.29)
description: API reference for qiskit.visualization.plot_bloch_vector in qiskit v0.29
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.visualization.plot_bloch_vector
---
<span id="qiskit-visualization-plot-bloch-vector" />
# qiskit.visualization.plot\_bloch\_vector
<Function id="qiskit.visualization.plot_bloch_vector" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.18/qiskit/visualization/state_visualization.py" signature="plot_bloch_vector(bloch, title='', ax=None, figsize=None, coord_type='cartesian')">
Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
**Parameters**
* **bloch** (*list\[double]*) array of three elements where \[\<x>, \<y>, \<z>] (Cartesian) or \[\<r>, \<theta>, \<phi>] (spherical in radians) \<theta> is inclination angle from +z direction \<phi> is azimuth from +x direction
* **title** (*str*) a string that represents the plot title
* **ax** (*matplotlib.axes.Axes*) An Axes to use for rendering the bloch sphere
* **figsize** (*tuple*) Figure size in inches. Has no effect is passing `ax`.
* **coord\_type** (*str*) a string that specifies coordinate type for bloch (Cartesian or spherical), default is Cartesian
**Returns**
A matplotlib figure instance if `ax = None`.
**Return type**
Figure
**Raises**
[**MissingOptionalLibraryError**](qiskit.aqua.MissingOptionalLibraryError "qiskit.aqua.MissingOptionalLibraryError") Requires matplotlib.
**Example**
```python
from qiskit.visualization import plot_bloch_vector
%matplotlib inline
plot_bloch_vector([0,1,0], title="New Bloch Sphere")
```
![../\_images/qiskit.visualization.plot\_bloch\_vector\_0\_0.png](/images/api/qiskit/0.29/qiskit.visualization.plot_bloch_vector_0_0.png)
</Function>