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) – 데이터 집합당 플롯할 용어 수입니다. 나머지는 '휴식'이라는 단일 막대로 만들어집니다. 여러 데이터 세트가 주어진 경우
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
레이즈
- 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에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.