Repository: Qiskit/qiskit

Issue:
MPL circuit drawer does not draw CCZ properly
Take the following example:
```python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate

qc = QuantumCircuit(3)
qc.append(ZGate().control(2, ctrl_state='01'), range(3))
```
The `text` and `latex` drawer outputs are the following:
```python
qc.draw('text')

q_0: ─■─
      │ 
q_1: ─o─
      │ 
q_2: ─■─
```
```python
qc.draw('latex')
```
![image](https://user-images.githubusercontent.com/766693/110315609-cd28db80-8009-11eb-80de-d082e1276a5b.png)

However, here is the `mpl` output:
```python
qc.draw('mpl')
```
![image](https://user-images.githubusercontent.com/766693/110315793-0a8d6900-800a-11eb-9fb9-688008202f89.png)



Discussion:
Hey! Can I give this a try?
Sure, I'll assign you 🙂 

Resolving patch:
diff --git a/qiskit/visualization/matplotlib.py b/qiskit/visualization/matplotlib.py
--- a/qiskit/visualization/matplotlib.py
+++ b/qiskit/visualization/matplotlib.py
@@ -996,12 +996,12 @@ def _draw_ops(self, verbose=False):
                 #
                 # draw controlled and special gates
                 #
-                # cz gate
-                elif op.name == 'cz':
+                # cz and mcz gates
+                elif op.name != 'z' and base_name == 'z':
                     num_ctrl_qubits = op.op.num_ctrl_qubits
                     self._set_ctrl_bits(op.op.ctrl_state, num_ctrl_qubits,
                                         q_xy, ec=ec, tc=tc, text=ctrl_text, qargs=op.qargs)
-                    self._ctrl_qubit(q_xy[1], fc=ec, ec=ec, tc=tc)
+                    self._ctrl_qubit(q_xy[-1], fc=ec, ec=ec, tc=tc)
                     self._line(qubit_b, qubit_t, lc=lc, zorder=PORDER_LINE + 1)
 
                 # cu1, cp, rzz, and controlled rzz gates (sidetext gates)


Test patch:
diff --git a/test/ipynb/mpl/references/big_gates.png b/test/ipynb/mpl/references/big_gates.png
Binary files a/test/ipynb/mpl/references/big_gates.png and b/test/ipynb/mpl/references/big_gates.png differ
diff --git a/test/ipynb/mpl/references/ctrl_labels.png b/test/ipynb/mpl/references/ctrl_labels.png
Binary files a/test/ipynb/mpl/references/ctrl_labels.png and b/test/ipynb/mpl/references/ctrl_labels.png differ
diff --git a/test/ipynb/mpl/references/cz.png b/test/ipynb/mpl/references/cz.png
new file mode 100644
Binary files /dev/null and b/test/ipynb/mpl/references/cz.png differ
diff --git a/test/ipynb/mpl/references/ghz_to_gate.png b/test/ipynb/mpl/references/ghz_to_gate.png
Binary files a/test/ipynb/mpl/references/ghz_to_gate.png and b/test/ipynb/mpl/references/ghz_to_gate.png differ
diff --git a/test/ipynb/mpl/references/scale_default.png b/test/ipynb/mpl/references/scale_default.png
Binary files a/test/ipynb/mpl/references/scale_default.png and b/test/ipynb/mpl/references/scale_default.png differ
diff --git a/test/ipynb/mpl/references/scale_double.png b/test/ipynb/mpl/references/scale_double.png
Binary files a/test/ipynb/mpl/references/scale_double.png and b/test/ipynb/mpl/references/scale_double.png differ
diff --git a/test/ipynb/mpl/references/scale_half.png b/test/ipynb/mpl/references/scale_half.png
Binary files a/test/ipynb/mpl/references/scale_half.png and b/test/ipynb/mpl/references/scale_half.png differ
diff --git a/test/ipynb/mpl/test_circuit_matplotlib_drawer.py b/test/ipynb/mpl/test_circuit_matplotlib_drawer.py
--- a/test/ipynb/mpl/test_circuit_matplotlib_drawer.py
+++ b/test/ipynb/mpl/test_circuit_matplotlib_drawer.py
@@ -25,7 +25,7 @@
 from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile
 from qiskit.test.mock import FakeTenerife
 from qiskit.visualization.circuit_visualization import _matplotlib_circuit_drawer
-from qiskit.circuit.library import XGate, MCXGate, HGate, RZZGate, SwapGate, DCXGate
+from qiskit.circuit.library import XGate, MCXGate, HGate, RZZGate, SwapGate, DCXGate, ZGate
 from qiskit.circuit.library import MCXVChain
 from qiskit.extensions import HamiltonianGate
 from qiskit.circuit import Parameter
@@ -234,6 +234,18 @@ def test_cnot(self):
 
         self.circuit_drawer(circuit, filename='cnot.png')
 
+    def test_cz(self):
+        """Test Z and Controlled-Z Gates"""
+        qr = QuantumRegister(4, 'q')
+        circuit = QuantumCircuit(qr)
+        circuit.z(0)
+        circuit.cz(0, 1)
+        circuit.append(ZGate().control(3, ctrl_state='101'), [0, 1, 2, 3])
+        circuit.append(ZGate().control(2), [1, 2, 3])
+        circuit.append(ZGate().control(1, ctrl_state='0', label='CZ Gate'), [2, 3])
+
+        self.circuit_drawer(circuit, filename='cz.png')
+
     def test_pauli_clifford(self):
         """Test Pauli(green) and Clifford(blue) gates"""
         qr = QuantumRegister(5, 'q')