def decimals(): with qml.tape.QuantumTape() as tape2: qml.RX(1.23456, wires=0) qml.Rot(1.2345, 2.3456, 3.456, wires=0) qml.expval(qml.PauliZ(0)) fig, ax = draw_mpl(tape2, decimals=2) plt.savefig(folder / "decimals.png") plt.close()
def wires_and_labels(tape): fig, ax = draw_mpl(tape, wire_options={ 'color': 'black', 'linewidth': 5 }, label_options={'size': 20}) plt.savefig(folder / "wires_labels.png") plt.close()
def rcparams(tape): plt.rcParams['patch.facecolor'] = 'white' plt.rcParams['patch.edgecolor'] = 'black' plt.rcParams['patch.linewidth'] = 2 plt.rcParams['patch.force_edgecolor'] = True plt.rcParams['lines.color'] = 'black' fig, ax = draw_mpl(tape) plt.savefig(folder / "rcparams.png") plt.close() plt.style.use('default')
def postprocessing(tape): fig, ax = draw_mpl(tape) fig.suptitle("My Circuit", fontsize="xx-large") options = { 'facecolor': "white", 'edgecolor': "#f57e7e", "linewidth": 6, "zorder": -1 } box1 = plt.Rectangle((-0.5, -0.5), width=3.0, height=4.0, **options) ax.add_patch(box1) ax.annotate("CSWAP", xy=(2, 2.5), xycoords='data', xytext=(2.8, 1.5), textcoords='data', arrowprops={'facecolor': 'black'}, fontsize=14) plt.savefig(folder / "postprocessing.png") plt.close()
def mpl_style(tape): with plt.style.context("Solarize_Light2"): fig, ax = draw_mpl(tape) plt.savefig(folder / "Solarize_Light2.png") plt.close()
def show_all_wires(tape): fig, ax = draw_mpl(tape, wire_order=["aux"], show_all_wires=show_all_wires) plt.savefig(folder / "show_all_wires.png") plt.close()
def wire_order(tape): fig, ax = draw_mpl(tape, wire_order=[3, 2, 1, 0]) plt.savefig(folder / "wire_order.png") plt.close()
def default(tape): fig, ax = draw_mpl(tape) plt.savefig(folder / "default.png") plt.close()