# Visualizing nice circuits in Qiskit

This is what drawing a circuit looks like in the Qiskit textbook:

and this is the ugly version I am stuck with in my own notebooks:

On their Prerequisites page they write:

However, there is no .qiskit file in my home directory, and I can't locate it anywhere else. I installed it simply with the usual pip install command, without setting up any virtual environment, so that may be the issue. I am not a Linux expert so perhaps there is something simple I am missing.

How can I set up this configuration file? Creating a .qiskit directory manually doesn't do the job.

• Rather than changing the default, you can request the mpl backend each time using .draw(output='mpl')'. – James Wootton Jan 29 at 22:47
• Awesome, thanks. Would still be nice to figure out where that damn file is stored though. – Oilobobolus Jan 29 at 22:53
• Hey! I wrote that "ugly" circuit drawer. I feel a bit disparaged ;) – luciano Jan 30 at 8:33
• Oops, sorry :) I should have rather called it charmingly rustic or tastefully minimalistic perhaps... – Oilobobolus Jan 30 at 20:39

As James noted in the comment. You can use the .draw( output = 'mpl', ... ) or to help you to get a nicer figure. That is, suppose I have the following circuit:

q_0: ┤ X ├┤M├─────────
├───┤└╥┘┌─┐
q_1: ┤ X ├─╫─┤M├──────
├───┤ ║ └╥┘┌─┐
q_2: ┤ H ├─╫──╫─┤M├───
├───┤ ║  ║ └╥┘┌─┐
q_3: ┤ H ├─╫──╫──╫─┤M├
└───┘ ║  ║  ║ └╥┘
c: 4/══════╩══╩══╩══╩═
0  1  2  3


which can be created by running the code:

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi

qreg_q = QuantumRegister(4, 'q')
creg_c = ClassicalRegister(4, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)

circuit.x(qreg_q[0])
circuit.x(qreg_q[1])
circuit.h(qreg_q[2])
circuit.h(qreg_q[3])
circuit.measure(qreg_q[0], creg_c[0])
circuit.measure(qreg_q[1], creg_c[1])
circuit.measure(qreg_q[2], creg_c[2])
circuit.measure(qreg_q[3], creg_c[3])


then by specifying:

circuit.draw( output = 'mpl', style={'name': 'bw'}, plot_barriers= True, initial_state = True, scale = 1)


I will get the figure:

and if i specify:

circuit.draw( output = 'latex',style={'name': 'bw'}, plot_barriers= True, initial_state = True, scale = 1)


I will get the figure:

and if you want to save the image file, then include the file name in the option. That is, something like:

circuit.draw( 'mpl',style={'name': 'bw'},filename= 'MyCircuit', plot_barriers= True, initial_state = True, scale = 1)
`