Skip to main content
IBM Quantum Platform

qiskit.visualization.plot_distribution

qiskit.visualization.plot_distribution(data, figsize=(7, 5), color=None, number_to_keep=None, sort='asc', target_string=None, legend=None, bar_labels=True, title=None, ax=None, filename=None)

GitHub

入力されたサンプリングデータから分布をプロットする。

パラメーター

  • data (list ordict) – これは、辞書のリスト、または表現する値を含む単一の辞書です(例: {‘001’: 130} )
  • figsize (tuple) – フィギュアのサイズ(インチ)。
  • color (list orstr) – 分布バーの色を表す文字列または文字列のリスト。
  • number_to_keep (int) – データセットごとにプロットする項の数。 残りは「レスト」と呼ばれる1本の棒にする。 複数のデータセットが指定された場合, number_to_keep は各データセットに個別に適用されるため, number_to_keep + 1 よりも棒グラフの数が多くなる可能性がある. number_to_keep は、X軸のソートではなく、合計値に適用される。
  • sort (string) – asc'、'desc'、'hamming'、'value'、または'value_desc'である。 value'または'value_desc'に設定すると、x軸は各ビット文字列の最大確率でソートされる。 デフォルトは「asc」。
  • target_string (str) – sort' が距離測定の場合、対象となる文字列。
  • legend (list) – データのラベルとして使用する文字列のリスト。 要素の数は、データの長さと一致している必要があります(データがリストの場合はその長さ、辞書の場合は1)
  • bar_labels (bool) – ヒストグラムの各バーに確率値のラベルを付ける。
  • title (str) – プロットのタイトルに使用する文字列
  • ax (matplotlib.axes.Axes) – 可視化出力に使用するオプションのAxesオブジェクト。 何も指定しない場合、新しい matplotlib Figure が作成され、使用されます。 さらに、指定された場合、冗長であるため、返されるFigureはない。
  • filename (str) – 画像を保存するファイルパス。

戻り値

ax kwargが設定されていない場合、レンダリングされた分布の数値。

戻りの型

matplotlib.Figure

レイズ

# Plot two counts in the same figure with legends and colors specified.

from qiskit.visualization import plot_distribution

counts1 = {'00': 525, '11': 499}
counts2 = {'00': 511, '11': 514}

legend = ['First execution', 'Second execution']

plot_distribution([counts1, counts2], legend=legend, color=['crimson','midnightblue'],
                title="New Distribution")

# You can sort the bitstrings using different methods.

counts = {'001': 596, '011': 211, '010': 50, '000': 117, '101': 33, '111': 8,
        '100': 6, '110': 3}

# Sort by the counts in descending order
dist1 = plot_distribution(counts, sort='value_desc')

# Sort by the hamming distance (the number of bit flips to change from
# one bitstring to the other) from a target string.
dist2 = plot_distribution(counts, sort='hamming', target_string='001')
前のコードからの出力。前のコードからの出力。前のコードからの出力。
このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。