【问题标题】:Using Google Colab and need help in output of plotting使用 Google Colab 并在绘图输出方面需要帮助
【发布时间】:2020-09-12 21:30:27
【问题描述】:

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

# 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

我得到如下输出:

【问题讨论】:

  • 我无法重现您的情况,我尝试使用示例 DataFrame 并显示图表
  • 它对我来说很好用,这里是screenshot。我建议重新启动运行时并重试
  • 好的,太好了!

标签: python pandas plot google-colaboratory


【解决方案1】:

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

%matplotlib inline
plt.close('all')

【讨论】:

    猜你喜欢
    • 2011-02-17
    • 1970-01-01
    • 2011-01-27
    • 2014-02-06
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多