pyqpanda.Visualization.bloch ============================ .. py:module:: pyqpanda.Visualization.bloch .. autoapi-nested-parse:: Bloch sphere Classes ------- .. autoapisummary:: pyqpanda.Visualization.bloch.Bloch Module Contents --------------- .. py:class:: 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. Args: 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. .. py:attribute:: fig :value: None .. py:attribute:: axes :value: None .. py:attribute:: background :value: False .. py:attribute:: figsize :value: [5, 5] .. py:attribute:: view .. py:attribute:: sphere_color :value: '#FFDDDD' .. py:attribute:: sphere_alpha :value: 0.2 .. py:attribute:: frame_color :value: 'gray' .. py:attribute:: frame_width :value: 1 .. py:attribute:: frame_alpha :value: 0.2 .. py:attribute:: xlabel :value: ['$x$', ''] .. py:attribute:: xlpos .. py:attribute:: ylabel :value: ['$y$', ''] .. py:attribute:: ylpos .. py:attribute:: zlabel :value: ['$\\left|0\\right>$', '$\\left|1\\right>$'] .. py:attribute:: zlpos .. py:attribute:: font_color .. py:attribute:: font_size :value: 20 .. py:attribute:: vector_color :value: ['#dc267f', '#648fff', '#fe6100', '#785ef0', '#ffb000'] .. py:attribute:: vector_width :value: 5 .. py:attribute:: vector_style :value: '-|>' .. py:attribute:: vector_mutation :value: 20 .. py:attribute:: point_color :value: ['b', 'r', 'g', '#CC6600'] .. py:attribute:: point_size :value: [25, 32, 35, 45] .. py:attribute:: point_marker :value: ['o', 's', 'd', '^'] .. py:attribute:: points :value: [] .. py:attribute:: vectors :value: [] .. py:attribute:: annotations :value: [] .. py:attribute:: savenum :value: 0 .. py:attribute:: point_style :value: [] .. py:method:: 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. .. py:method:: clear() Resets Bloch sphere data sets to empty. .. py:method:: 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. .. py:method:: add_vectors(vectors) Add a list of vectors to Bloch sphere. Args: vectors (array_like): Array with vectors of unit length or smaller. .. py:method:: 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. .. py:method:: make_sphere() Plots Bloch sphere and data sets. .. py:method:: render(title='') Render the Bloch sphere and its data sets in on given figure and axes. .. py:method:: plot_back() back half of sphere .. py:method:: plot_front() front half of sphere .. py:method:: plot_axes() axes .. py:method:: plot_axes_labels() axes labels .. py:method:: plot_vectors() Plot vector .. py:method:: plot_points() Plot points .. py:method:: plot_annotations() Plot annotations .. py:method:: show(title='') Display Bloch sphere and corresponding data sets. .. py:method:: 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.