@@ -327,3 +327,48 @@ For example
327
327
q2: ──────o──|──|────o──|──|──H─U1─U1────────|─|─
328
328
q3: ─────────o──|───────o──|────o──|──H─U1───|─x─
329
329
q4: ────────────o──────────o───────o────o──H─x───
330
+
331
+ How to visualize a circuit with style?
332
+ --------------------------------------
333
+
334
+ Qibo is able to draw a circuit using ``matplotlib `` library by calling the function ``plot_circuit ``. It also have built-in styles ready to use
335
+ and also it is possible to apply custom styles to the circuit. The function is able to cluster the gates to reduce the circuit depth.
336
+ The built-in styles are: ``garnacha ``, ``fardelejo ``, ``quantumspain ``, ``color-blind ``, ``cachirulo `` or custom dictionary.
337
+
338
+ For example, we can draw the QFT circuit for 5-qubits:
339
+
340
+ .. testcode ::
341
+
342
+ import matplotlib.pyplot as plt
343
+ import qibo
344
+ from qibo import gates, models
345
+ from qibo.models import QFT
346
+
347
+ # new plot function based on matplotlib
348
+ from qibo.ui import plot_circuit
349
+
350
+ %matplotlib inline
351
+
352
+ # create a 5-qubits QFT circuit
353
+ c = QFT(5)
354
+ c.add(gates.M(qubit) for qubit in range(2))
355
+
356
+ # print circuit with default options (default black & white style, scale factor of 0.6 and clustered gates)
357
+ plot_circuit(c);
358
+
359
+ # print the circuit with built-int style "garnacha", clustering gates and a custom scale factor
360
+ # built-in styles: "garnacha", "fardelejo", "quantumspain", "color-blind", "cachirulo" or custom dictionary
361
+ plot_circuit(c, scale = 0.8, cluster_gates = True, style="garnacha");
362
+
363
+ # plot the Qibo circuit with a custom style
364
+ custom_style = {
365
+ "facecolor" : "#6497bf",
366
+ "edgecolor" : "#01016f",
367
+ "linecolor" : "#01016f",
368
+ "textcolor" : "#01016f",
369
+ "fillcolor" : "#ffb9b9",
370
+ "gatecolor" : "#d8031c",
371
+ "controlcolor" : "#360000"
372
+ }
373
+
374
+ plot_circuit(c, scale = 0.8, cluster_gates = True, style=custom_style);
0 commit comments