How to change the drawer style?

I have set the qml.drawer.use_style(‘black_white’), but it doesn’t seem to work

import pennylane as qml
qml.drawer.use_style('black_white')
# Set up the drawer (Corrected n_layers to 16 to include layer 15)
drawer = qml.drawer.MPLDrawer(wire_map={i: i for i in range(3)}, n_layers=16)
drawer.label(["qubit 0", "qubit 1", "qubit 2"])

# --- Your circuit drawing code ---

# Use a for loop to place individual gates instead of a block
for i in range(3):
    drawer.box_gate(layer=0, wires=i, text="RY")
    drawer.box_gate(layer=1, wires=i, text="H")
    
    drawer.box_gate(layer=3, wires=i, text="RZ")
    drawer.box_gate(layer=4, wires=i, text="RX")
    drawer.box_gate(layer=5, wires=i, text="RZ")

# CNOTs are fine as they are
drawer.CNOT(layer=6, wires=(0, 1))
drawer.CNOT(layer=7, wires=(1, 2))

# Use a for loop for these gates too
for i in range(3):
    drawer.box_gate(layer=9, wires=i, text="RX")
    drawer.box_gate(layer=10, wires=i, text="RZ")
    drawer.box_gate(layer=11, wires=i, text="RZ")

# CNOTs and measures are fine
drawer.CNOT(layer=12, wires=(0, 1))
drawer.CNOT(layer=13, wires=(1, 2))
drawer.measure(layer=15, wires=0)
drawer.measure(layer=15, wires=1)
drawer.measure(layer=15, wires=2)

drawer.fig.suptitle('My Circuit', fontsize='xx-large')

It still produces the figure

Hi @unbelievetable , welcome to the Forum!

There’s currently a bug where qml.drawer.use_style is not working with the MPLDrawer (issue #8114 for future reference).

Fortunately there’s an easy workaround! Instead of using use_style you can call the style directly: qml.drawer.style._black_white() . You can use other styles too by just using style and adding an underscore before the name of the style.
So, to summarize, qml.drawer.use_style('black_white') doesn’t work, but qml.drawer.style._black_white() does work.

There’s a longer discussion on this issue and drawing options in Forum thread #8897 in case you want to take a look!

Let me know if this solves your issue!