qulacsvis.visualization.matplotlib module

class qulacsvis.visualization.matplotlib.MPLCircuitlDrawer(circuit: qulacsvis.models.circuit.CircuitData, *, dpi: int = 72, scale: float = 0.6)[source]

Bases: object

Drawing a circuit using Matplotlib.

Parameters
  • circuit (CircuitData) – A quantum circuit to be drawn.

  • dpi (int optional default=72) – The resolution of the figure.

  • scale (float optional default=0.6) – The scale of the figure.

_figure

The figure of the circuit.

Type

matplotlib.figure.Figure

_ax

The axes of the figure.

Type

matplotlib.axes.Axes

_circuit

The quantum circuit to be drawn.

Type

CircuitData

_fig_scale_factor

The scale factor of the figure.

Type

float

Examples

>>> from qulacs import QuantumCircuit
>>> from qulacsvis.qulacs.circuit import to_model
>>> from qulacsvis.visualization import MPLCircuitlDrawer
>>> import matplotlib.pyplot as plt
>>>
>>> circuit = QuantumCircuit(3)
>>> circuit.add_X_gate(0)
>>> circuit.add_Y_gate(1)
>>> circuit.add_Z_gate(2)
>>>
>>> drawer = MPLCircuitlDrawer(to_model(circuit))
>>> drawer.draw()
>>> plt.show()
draw(*, debug: bool = False, filename: Optional[str] = None) matplotlib.figure.Figure[source]

Draw the circuit.

Parameters
  • debug (bool optional default=False) – If True, draw the circuit with the axes of the figure.

  • filename (Optional[str] optional default=None) – File name to save the drawing mpl image

Returns

self._figure – The figure of the circuit.

Return type

matplotlib.figure.Figure