qiskit.visualization.plot_histogram
qiskit.visualization.plot_histogram(data, figsize=None, color=None, number_to_keep=None, sort='asc', target_string=None, legend=None, bar_labels=True, title=None, ax=None, filename=None)
入力カウントデータのヒストグラムをプロットする。
パラメーター
- 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
レイズ
- MissingOptionalLibraryError - Matplotlib。
- VisualizationError - 凡例が提供され、長さが入力データと一致しない場合。
- VisualizationError - 入力は Counts または dict でなければならない
例
# Plot two counts in the same figure with legends and colors specified.
from qiskit.visualization import plot_histogram
counts1 = {'00': 525, '11': 499}
counts2 = {'00': 511, '11': 514}
legend = ['First execution', 'Second execution']
plot_histogram([counts1, counts2], legend=legend, color=['crimson','midnightblue'],
title="New Histogram")
# 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
hist1 = plot_histogram(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.
hist2 = plot_histogram(counts, sort='hamming', target_string='001')


このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。