6.8. visualization#

plot_hist(ensemble: dict, style: str = 'geqo', show_bar_labels: bool = False, intermediate_bins: int = 10, filename: str = None, **kwargs)[source]#

Plot histograms of the measurement results.

Parameters:
  • ensemble (dict) – The dictionary that stores the probability and density matrix of each measurement outcome.

  • style (str, optional) – The predefined style to use for the histograms. Defaults to geqo.

  • show_bar_labels (bool, optional) – Whether to display the numerical values on the histogram bars. Defaults to False.

  • intermediate_bins (int, optional) – The number of bins displayed in the last histogram if there are more than 64 measurement outcomes. Defaults to 10

  • filename (str, optional) – If provided, the output PNG will be saved with this filename. Defaults to None.

  • **kwargs – Additional styling options passed to the plotting function.

Returns:

The matplotlib Figure object containing the histogram plots.

Return type:

matplotlib.figure.Figure

plot_latex(seq: Sequence, backend: Simulator = None, decompose_subseq: bool = False, pack: bool = True, fold: int = 9, greek_symbol: bool = True, filename: str = None, return_quantikz: bool = False, **kwargs)[source]#

Plot a LaTeX-style (quantikz) quantum circuit diagram from a geqo Sequence.

Parameters:
  • seq (Sequence) – The geqo Sequence to visualize.

  • backend (Simulator, optional) – The simulator backend used to resolve parameter values. Defaults to None.

  • decompose_subseq (bool, optional) – Whether to decompose subsequences within the main sequence. Defaults to False.

  • pack (bool, optional) – Whether to compactify the circuit by placing non-conflicting gates in the same column. Defaults to True.

  • fold (int, optional) – Maximum number of lines to show before folding the circuit. Defaults to 9.

  • greek_symbol (bool, optional) – Whether to render gate names using Greek letters. Defaults to True.

  • filename (str, optional) – If provided, the output PNG will be saved with this filename. Defaults to None.

  • return_quantikz (bool, optional) – If True, the quantikz LaTeX code will be returned and printed. Defaults to False.

  • **kwargs – Additional styling options passed to the LaTeX generator.

Returns:

The rendered quantum circuit image. str (optional): The LaTeX (quantikz) code, if return_quantikz is True.

Return type:

PIL.Image

plot_mpl(seq: Sequence, backend: Simulator = None, decompose_subseq: bool = False, pack: bool = True, fold: int = 25, style: str = None, greek_symbol: bool = True, filename: str = None, **kwargs)[source]#

Plot a matplotlib-style quantum circuit diagram from a geqo Sequence.

Parameters:
  • seq (Sequence) – The geqo Sequence to visualize.

  • backend (Simulator, optional) – The simulator backend used to resolve parameter values. Defaults to None.

  • decompose_subseq (bool, optional) – Whether to decompose subsequences within the main sequence. Defaults to False.

  • pack (bool, optional) – Whether to compactify the circuit by placing non-conflicting gates in the same column. Defaults to True.

  • fold (int, optional) – Maximum number of columns to show before folding the circuit. Defaults to 25.

  • style (str, optional) – Predefined plot style to be applied. Defaults to None (black and white theme).

  • greek_symbol (bool, optional) – Whether to render gate names using Greek letters. Defaults to True.

  • filename (str, optional) – If provided, the output PNG will be saved with this filename. Defaults to None.

  • **kwargs – Additional styling options passed to the matplotlib-style circuit generator.

Returns:

The matplotlib-style quantum circuit diagram.

Return type:

matplotlib.figure.Figure

tolatex(seq: Sequence, backend: Simulator = None, decompose_subseq: bool = False, pack=True, fold: int = 9, greek_symbol: bool = True, **kwargs) str[source]#

Convert a Sequence object into LaTeX quantikz code for visualizing quantum circuits.

Parameters:
  • seq (Sequence) – The geqo Sequence to convert.

  • backend (Simulator, optional) – The simulator instance used for resolving symbolic or numeric values in the circuit.

  • decompose_subseq (bool, optional) – Whether to decompose any subsequences inside the main sequence. Defaults to False.

  • pack (bool, optional) – Whether to compactify the circuit by placing non-conflicting operations in the same column. Defaults to True.

  • fold (int, optional) – The maximum number of columns to display before folding the circuit. Defaults to 9.

  • greek_symbol (bool, optional) – Whether to convert gate names into Greek letters. Defaults to True.

  • **kwargs – Additional styling parameters for customizing the output.

Returns:

The LaTeX (quantikz) code representing the circuit diagram.

Return type:

str