qiskit.visualization.plot_state_city
qiskit.visualization.plot_state_city(state, title='', figsize=None, color=None, alpha=1, ax_real=None, ax_imag=None, *, filename=None)
양자 상태의 도시 풍경을 플롯합니다.
밀도 행렬 rho의 실수 부분과 허수 부분의 막대 그래프(2차원) 두 개( 3d )를 플롯합니다.
매개변수
- state (Statevector orDensityMatrix or ndarray) – n-큐비트 양자 상태입니다.
- title (str) – 플롯 제목을 나타내는 문자열
- figsize (tuple) – 그림 크기(인치).
- color (list) – 행렬 요소의 실제 및 가상 구성 요소에 대한 색상을 제공하는 len=2 목록입니다.
- alpha (float) – 막대의 투명도 값
- ax_real (matplotlib.axes.Axes) – 시각화 출력에 사용할 선택적 축 개체입니다. 아무것도 지정하지 않으면 새 matplotlib 그림이 생성되어 사용됩니다. Ax_imag 없이 지정하면 실제 컴포넌트 플롯만 생성됩니다. 또한 지정한 경우 중복되므로 반환되는 그림이 없습니다.
- ax_imag (matplotlib.axes.Axes) – 시각화 출력에 사용할 선택적 축 개체입니다. 아무것도 지정하지 않으면 새 matplotlib 그림이 생성되어 사용됩니다. Ax_real 없이 지정하면 가상의 컴포넌트 플롯만 생성됩니다. 또한 지정한 경우 중복되므로 반환되는 그림이 없습니다.
- filename (str | None) – 이미지를 저장할 선택적 파일 경로입니다. 명시되지 않은 경우, 시각화를 위한 파일이 생성되지 않습니다.
None이 옵션이 설정되면 이 함수의 반환값은.가 됩니다.
리턴
ax_real 및 ax_imag kwargs가 설정되지 않은 경우 시각화의 matplotlib.Figure
리턴 유형
레이즈
- MissingOptionalLibraryError – matplotlib이 필요합니다.
- ValueError - 'color'가 len=2 의 목록이 아닌 경우.
- VisualizationError – 입력이 유효한 N-큐비트 상태가 아닌 경우.
예제
# You can choose different colors for the real and imaginary parts of the density matrix.
from qiskit import QuantumCircuit
from qiskit.quantum_info import DensityMatrix
from qiskit.visualization import plot_state_city
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
state = DensityMatrix(qc)
plot_state_city(state, color=['midnightblue', 'crimson'], title="New State City")
# You can make the bars more transparent to better see the ones that are behind
# if they overlap.
import numpy as np
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_state_city
from qiskit import QuantumCircuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc = QuantumCircuit(2)
qc.h([0, 1])
qc.cz(0,1)
qc.ry(np.pi/3, 0)
qc.rx(np.pi/5, 1)
state = Statevector(qc)
plot_state_city(state, alpha=0.6)
이 페이지가 도움이 되었습니까?
GitHub에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.