mimiqcircuits.visualization.results

Functions

plothistogram(results[, num_outcomes, ...])

Plot a bar chart of the most sampled classical states.

plothistogram(results, num_outcomes=15, mimiqstyle=True, nobitstrings=False)[source]

Plot a bar chart of the most sampled classical states.

Each bar is one sampled state, labelled with tointeger() in hexadecimal and, unless nobitstrings is set, its bits written inside the bar. Bars are sorted by count, highest first. The title shows the simulator and, if there are any, the range of fidelity estimates.

Parameters:
  • results (QCSResults) – The results to plot. They must contain samples.

  • num_outcomes (int) – The maximum number of states plotted. Defaults to 15.

  • mimiqstyle (bool) – If True, use the MIMIQ plot style and show the figure with plt.show(). If False, use the current matplotlib style and do not show it. Defaults to True.

  • nobitstrings (bool) – If True, do not write the bits inside the bars. Defaults to False.

Returns:

The figure.

Return type:

matplotlib.figure.Figure

Raises:
  • TypeError – If results is not a QCSResults.

  • ValueError – If results has no samples, for example because the circuit has no measurement.

Examples

>>> from mimiqcircuits import *
>>> from mimiqcircuits.visualization import plothistogram
>>> res = QCSResults(
...     simulator="MIMIQ-StateVector",
...     version="1.0",
...     fidelities=[1.0],
...     cstates=[BitString("00"), BitString("11"), BitString("11")],
... )

Plot without showing the window, then save the figure.

>>> fig = plothistogram(res, mimiqstyle=False)
>>> fig.savefig("histogram.png")