# Draw a circuit with symbolic variables

Hello! Is there a way to draw a quantum circuit with symbolic variables as parameters?
For instance, getting qml.draw_mpl to draw Rot(x,y,z)

Hey @joaofbravo,

There’s not an easy way to do this at the moment. Every operator has a label method that returns something like, e.g., for the Hadamard gate, base_label or "H".

So is there a way to tweak that label so it outputs H(\theta_i) instead of H(1.123) for example?

I guess you can do the following. Let’s say I want to relabel all Hadamards — labelled as H when drawn — to potato

import pennylane as qml

def label(self, *args, **kwargs):
return "potato"

dev = qml.device("default.qubit")

@qml.qnode(dev)
def circuit():
return qml.state()

print(qml.draw(circuit)())

0: ──potato─┤  State

1 Like

Thanks, that works for now. It also works with Latex and qml.draw_mpl:

class Rot(qml.Rot):
def label(self, *args, **kwargs):
return 'Rot\n($\\theta_1, \\theta_2, \\theta_3$)'

dev = qml.device(device, wires=1)

@qml.qnode(dev)
def circuit(x):
Rot(x[0], x[1], x[2], wires=0)
return qml.expval(qml.PauliZ(0))

qml.draw_mpl(circuit, style='pennylane')([1, 2, 3])
plt.show()


1 Like