pyqpanda.Visualization.bloch

Bloch sphere

Module Contents

Classes

Bloch

Class for plotting data on the Bloch sphere. Valid data can be

class pyqpanda.Visualization.bloch.Bloch(fig=None, axes=None, view=None, figsize=None, background=False)[源代码]

Class for plotting data on the Bloch sphere. Valid data can be either points, vectors, or qobj objects. Attributes:

axes (instance):

User supplied Matplotlib axes for Bloch sphere animation.

fig (instance):

User supplied Matplotlib Figure instance for plotting Bloch sphere.

font_color (str):

Color of font used for Bloch sphere labels.

font_size (int):

Size of font used for Bloch sphere labels.

frame_alpha (float):

Sets transparency of Bloch sphere frame.

frame_color (str):

Color of sphere wireframe.

frame_width (int):

Width of wireframe.

point_color (list):

List of colors for Bloch sphere point markers to cycle through. i.e. By default, points 0 and 4 will both be blue ('b').

point_marker (list):

List of point marker shapes to cycle through.

point_size (list):

List of point marker sizes. Note, not all point markers look the same size when plotted!

sphere_alpha (float):

Transparency of Bloch sphere itself.

sphere_color (str):

Color of Bloch sphere.

figsize (list):

Figure size of Bloch sphere plot. Best to have both numbers the same; otherwise you will have a Bloch sphere that looks like a football.

vector_color (list):

List of vector colors to cycle through.

vector_width (int):

Width of displayed vectors.

vector_style (str):

Vector arrowhead style (from matplotlib's arrow style).

vector_mutation (int):

Width of vectors arrowhead.

view (list):

Azimuthal and Elevation viewing angles.

xlabel (list):

List of strings corresponding to +x and -x axes labels, respectively.

xlpos (list):

Positions of +x and -x labels respectively.

ylabel (list):

List of strings corresponding to +y and -y axes labels, respectively.

ylpos (list):

Positions of +y and -y labels respectively.

zlabel (list):

List of strings corresponding to +z and -z axes labels, respectively.

zlpos (list):

Positions of +z and -z labels respectively.

set_label_convention(convention)[源代码]

Set x, y and z labels according to one of conventions. Args:

convention (str):
One of the following:
  • "original"

  • "xyz"

  • "sx sy sz"

  • "01"

  • "polarization jones"

  • "polarization jones letters"

see also: http://en.wikipedia.org/wiki/Jones_calculus - "polarization stokes" see also: http://en.wikipedia.org/wiki/Stokes_parameters

Raises:

Exception: If convention is not valid.

clear()[源代码]

Resets Bloch sphere data sets to empty.

add_points(points, meth='s')[源代码]

Add a list of data points to Bloch sphere. Args:

points (array_like):

Collection of data points.

meth (str):

Type of points to plot, use 'm' for multicolored, 'l' for points connected with a line.

add_vectors(vectors)[源代码]

Add a list of vectors to Bloch sphere. Args:

vectors (array_like):

Array with vectors of unit length or smaller.

add_annotation(state_or_vector, text, **kwargs)[源代码]

Add a text or LaTeX annotation to Bloch sphere, parameterized by a qubit state or a vector. Args:

state_or_vector (array_like):

Position for the annotation. Qobj of a qubit or a vector of 3 elements.

text (str):

Annotation text. You can use LaTeX, but remember to use raw string e.g. r"$langle x rangle$" or escape backslashes e.g. "$\langle x \rangle$".

**kwargs:

Options as for mplot3d.axes3d.text, including: fontsize, color, horizontalalignment, verticalalignment.

Raises:

Exception: If input not array_like or tuple.

make_sphere()[源代码]

Plots Bloch sphere and data sets.

render(title='')[源代码]

Render the Bloch sphere and its data sets in on given figure and axes.

plot_back()[源代码]

back half of sphere

plot_front()[源代码]

front half of sphere

plot_axes()[源代码]

axes

plot_axes_labels()[源代码]

axes labels

plot_vectors()[源代码]

Plot vector

plot_points()[源代码]

Plot points

plot_annotations()[源代码]

Plot annotations

show(title='')[源代码]

Display Bloch sphere and corresponding data sets.

save(name=None, output='png', dirc=None)[源代码]

Saves Bloch sphere to file of type format in directory dirc. Args:

name (str):

Name of saved image. Must include path and format as well. i.e. '/Users/Paul/Desktop/bloch.png' This overrides the 'format' and 'dirc' arguments.

output (str):

Format of output image.

dirc (str):

Directory for output images. Defaults to current working directory.