【问题标题】:How to keep visualizations (i.e. draw('mpl')) displayed while other code is calledHow to keep visualizations (i.e. draw(\'mpl\')) displayed while other code is called
【发布时间】:2022-12-27 06:21:13
【问题描述】:

I would like to be able to save and call a visualization, then have it show in-between other code. I know with MatPlotLib, you can do plt.show(), is there anything like that for Qiskit?

def test():
  return plot_bloch_multivector(circ)

print("This is what the plot looks like")
test()
print("See? Anyway...")
# more code

Output:

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

Desired output:

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

I am using Google Colab (ver. 3.7.15).

【问题讨论】:

    标签: matplotlib qiskit


    【解决方案1】:

    In any jupyter notebook (including Google Colab), you can display an object with display

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

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 2022-11-09
      • 2022-12-02
      • 2022-12-02
      • 2022-12-26
      • 1970-01-01
      • 1970-01-01
      • 2022-12-14
      • 2022-12-19
      相关资源
      最近更新 更多