gpt4 book ai didi

python - 为什么 '%matplotlib inline' 在 python 脚本中不起作用?

转载 作者:太空狗 更新时间:2023-10-29 22:17:57 27 4
gpt4 key购买 nike

以下不起作用:

enter image description here

但这在 Jupiter Notebook 中完全有效。

enter image description here

如果我只是将其注释掉,则图表不会显示。 (也许它无论如何都不会出现)

import pandas as pd
import matplotlib

from numpy.random import randn
import numpy as np

import matplotlib.pyplot as plt

df = pd.read_csv('data/playgolf.csv', delimiter='|' )
print(df.head())

hs = df.hist(['Temperature','Humidity'], bins=5)
print(hs)

最佳答案

其他答案和评论已经充分详细说明了为什么 %matplotlib inline 不能在 python 脚本中工作。

解决实际问题,就是在脚本中显示剧情,答案是使用

plt.show()

在脚本的末尾。

关于python - 为什么 '%matplotlib inline' 在 python 脚本中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44225002/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com