如何在调用其他代码时保持可视化(即 draw('mpl'))显示



我希望能够保存和调用可视化,然后在其他代码之间显示它。我知道有了MatPlotLib,你可以做plt.show((,奇思特有这样的东西吗?

def test():
return plot_bloch_multivector(circ)
print("This is what the plot looks like")
test()
print("See? Anyway...")
# more code

输出:

This is what the plot looks like
See? Anyway...

期望输出:

This is what the plot looks like
# O O O (displayed bloch multivector)
See? Anyway...

我正在使用Google Colab(版本3.7.15(。

在任何jupyter笔记本电脑(包括Google Colab(中,您都可以显示带有display的对象

def test():
return plot_bloch_multivector(circ)
print("This is what the plot looks like")
display(test())  # <----------------------
print("See? Anyway...")

最新更新