qiskit-metapackage icon indicating copy to clipboard operation
qiskit-metapackage copied to clipboard

.draw(output = 'mpl"), plot_bloch_multivector etc. produce two plots even after removing %matplotlib inline

Open albspe opened this issue 3 years ago • 2 comments

Informations

  • Qiskit version: 'qiskit': '0.29.0' 'qiskit-terra': '0.18.1', 'qiskit-aer': '0.8.2', 'qiskit-ignis': '0.6.0', 'qiskit-ibmq-provider': '0.16.0', 'qiskit-aqua': '0.9.4', 'qiskit-nature': '0.1.5', qiskit-finance': '0.2.0', 'qiskit-optimization': '0.2.1', 'qiskit-machine-learning': '0.2.0'

  • Python version: 3.9.6 with ipython 7.20.0

  • Operating system: Windows 10 using WSL 2

What is the current behavior?

Using the .draw(output = 'mpl') for a QuantumCircuit object or the function plot_bloch_multivector results in two copies of the same picture even if %matplotlib inline has been disabled.

Steps to reproduce the problem

This is the code I run in one code block:

import qiskit
from qiskit import QuantumCircuit, execute, Aer
from qiskit.visualization import plot_bloch_multivector
import math

qc = QuantumCircuit(2)
qc.h(0)
qc.h(1)
qc.draw(output='mpl', scale=1)

followed by the next code block:

out_vector = execute(qc, Aer.get_backend('statevector_simulator')).result().get_statevector()
plot_bloch_multivector(out_vector, reverse_bits=True)

What is the expected behavior?

Should get only one single plot per code block

Suggested solutions

The suggested solution from https://github.com/Qiskit/qiskit/issues/1265 of removing %matplotlib inline does not work

albspe avatar Aug 31 '21 21:08 albspe

Even i am facing the same issue with the following version {'qiskit-terra': '0.18.1', 'qiskit-aer': '0.8.2', 'qiskit-ignis': '0.6.0', 'qiskit-ibmq-provider': '0.16.0', 'qiskit-aqua': '0.9.4', 'qiskit': '0.29.0', 'qiskit-nature': None, 'qiskit-finance': None, 'qiskit-optimization': None, 'qiskit-machine-learning': None}

jaswin90 avatar Sep 02 '21 07:09 jaswin90

Hey @albspe @jaswin90 This was fixed in Qiskit/qiskit-terra#6889. Maybe there could be any kernel problem you can try the solution suggested.

divshacker avatar Sep 02 '21 08:09 divshacker

Should hopefully have been fixed by Qiskit/qiskit-terra#6889. Please feel free to re-open on the Qiskit Terra repo if that's not the case.

jakelishman avatar Mar 20 '23 12:03 jakelishman