gpt4 book ai didi

python - Jupyter Notebook - 在函数内部绘图 - 图未绘制

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

<分区>

我想从一个类中调用一个函数,我想在其中绘制多个图形。没有抛出错误,但我没有收到情节,但只有:

#############################################
Histograms of the continuous data:
#############################################
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>

我使用的代码是:

class Pipeline:
import matplotlib.pyplot as plt
global plt
from matplotlib import style
style.use('ggplot')


def __init__(self,goal):
self.goal = goal


def examine(self,dataset):
# Check for categorical and continous data
continuous = []
categorical = []
for n,i in enumerate(dataset.columns):
if isinstance(dataset[i][1],str):
categorical.append(dataset.columns[n])
else:
continuous.append(dataset.columns[n])

continuous_data = dataset[continuous]
categorical_data = dataset[categorical]

#Plot the histograms of the continuous data
print('#############################################')
print('Histograms of the continuous data:')
print('#############################################')

for col in continuous_data.columns:
fig = plt.figure()
ax = continuous_data[col].hist()
ax.set_title(col)
plt.show()







pipe = Pipeline('C')
pipe.examine(data)

我想知道,因为如果我第二次运行相同的代码,它会按照建议绘制图形。感谢任何帮助!

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