擅长:python、mysql、java
<p>答案是由阴谋小组提供的,我在这里分享。
<code>plotly.offline.plot</code>将绘图保存到同名文件中,因此可能会偶尔出现这样的问题:在文件完全写入磁盘之前,浏览器正在打开,从而显示前面的图。在</p>
<p>以下方法使用<code>plotly.io</code>解决了该问题,并一次绘制一个图形:</p>
<pre><code>import plotly_express as px
import plotly.io as pio
pio.renderers.default = 'browser'
iris = px.data.iris()
scatter_plot = px.scatter(iris, x="sepal_width", y="sepal_length")
pio.show(scatter_plot)
</code></pre>