diff --git a/qiskit/visualization/matplotlib.py b/qiskit/visualization/matplotlib.py index 8d0460415bd1..5b2aa1063961 100644 --- a/qiskit/visualization/matplotlib.py +++ b/qiskit/visualization/matplotlib.py @@ -224,14 +224,17 @@ def _custom_multiqubit_gate(self, xy, cxy=None, fc=None, wide=True, text=None, clip_on=True, zorder=PORDER_TEXT) if text: + if text in self._style.dispcol: + disp_text = "${}$".format(self._style.disptex[text]) - disp_text = text + else: + disp_text = text if subtext: - self.ax.text(xpos, ypos + 0.5 * height, disp_text, ha='center', + self.ax.text(xpos, ypos + 0.4 * height, disp_text, ha='center', va='center', fontsize=self._style.fs, color=self._style.gt, clip_on=True, zorder=PORDER_TEXT) - self.ax.text(xpos, ypos + 0.3 * height, subtext, ha='center', + self.ax.text(xpos, ypos + 0.2 * height, subtext, ha='center', va='center', fontsize=self._style.sfs, color=self._style.sc, clip_on=True, zorder=PORDER_TEXT) @@ -293,6 +296,7 @@ def _gate(self, xy, fc=None, wide=False, text=None, subtext=None): if text in self._style.dispcol: disp_text = "${}$".format(self._style.disptex[text]) + else: disp_text = text if subtext: @@ -1012,7 +1016,7 @@ def _draw_ops(self, verbose=False): # Custom gate else: self._custom_multiqubit_gate(q_xy, c_xy, wide=_iswide, - text=op.op.label or op.name) + text=op.op.label or op.name, subtext=param) # # draw multi-qubit gates (n=3) # diff --git a/qiskit/visualization/qcstyle.py b/qiskit/visualization/qcstyle.py index 49b0708dc70c..b34eba011188 100644 --- a/qiskit/visualization/qcstyle.py +++ b/qiskit/visualization/qcstyle.py @@ -62,8 +62,11 @@ def __init__(self): 'tdg': 'T^\\dagger', 'r': 'R', 'rx': 'R_x', + 'rxx': 'R_{xx}', 'ry': 'R_y', + 'ryy': 'R_{yy}', 'rz': 'R_z', + 'rzx': 'R_{zx}', 'reset': '\\left|0\\right\\rangle' } self.dispcol = { @@ -88,8 +91,11 @@ def __init__(self): 'tdg': other_color, 'r': other_color, 'rx': other_color, + 'rxx': other_color, 'ry': other_color, + 'ryy': other_color, 'rz': other_color, + 'rzx': other_color, 'reset': non_gate_color, 'target': '#ffffff', 'multi': other_color, @@ -163,8 +169,11 @@ def __init__(self): 'tdg': 'T^\\dagger', 'r': 'R', 'rx': 'R_x', + 'rxx': 'R_{xx}', 'ry': 'R_y', + 'ryy': 'R_{yy}', 'rz': 'R_z', + 'rzx': 'R_{zx}', 'reset': '\\left|0\\right\\rangle' } self.dispcol = { @@ -184,8 +193,11 @@ def __init__(self): 'tdg': '#ffffff', 'r': '#ffffff', 'rx': '#ffffff', + 'rxx': '#ffffff', 'ry': '#ffffff', + 'ryy': '#ffffff', 'rz': '#ffffff', + 'rzx': '#ffffff', 'reset': '#ffffff', 'target': '#ffffff', 'meas': '#ffffff',