使用谷歌Colab和需要帮助的打印输出

2024-03-29 11:21:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我在GoogleColab上运行了以下代码,但我认为它应该在输出上绘制一个图表!这是对还是错? 代码:

# plotting a scatter matrix
from matplotlib import cm
from pandas.plotting import scatter_matrix

X = fruits[['height', 'width', 'mass', 'color_score']]
y = fruits['fruit_label']
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

cmap = cm.get_cmap('gnuplot')
scatter=pd.plotting.scatter_matrix(X_train, c= y_train, marker = 'o', s=40, hist_kwds={'bins':15}, 
figsize=(9,9), cmap=cmap)
scatter

我得到的输出如下:

enter image description here


Tags: 代码fromtestimportmatplotlib图表绘制cm
1条回答
网友
1楼 · 发布于 2024-03-29 11:21:59

感谢所有试图解决我问题的人! 我刚刚找到了解决方案。我在开始时使用了以下代码:

%matplotlib inline
plt.close('all')

相关问题 更多 >