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) – 데이터 집합당 플롯할 용어 수입니다. 나머지는 '휴식'이라는 단일 막대로 만들어집니다. 여러 데이터 세트가 주어진 경우 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) – '정렬'이 거리 측정값인 경우 대상 문자열입니다.
  • legend (list) – 데이터의 레이블로 사용할 문자열 목록입니다. 항목의 개수는 데이터의 길이와 일치해야 합니다(데이터가 리스트인 경우, 딕셔너리인 경우 1)
  • bar_labels (bool) – 히스토그램의 각 막대에 확률 값으로 레이블을 지정합니다.
  • title (str) – 플롯 제목에 사용할 문자열
  • ax (matplotlib.axes.Axes) – 시각화 출력에 사용할 선택적 축 개체입니다. 아무것도 지정하지 않으면 새 matplotlib 그림이 생성되어 사용됩니다. 또한 지정한 경우 중복되므로 반환되는 그림이 없습니다.
  • 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에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.