简体   繁体   English

散点 plot 矩阵

[英]Scatter plot matrix

I'd like to get a scatter plot for all my matrix.我想为我的所有矩阵获取散点图 plot。

I found the module seaborn, and I did something like this.我找到了模块 seaborn,我做了这样的事情。

import seaborn as sns

data_ = pd.read_csv('/content/drive/My Drive/Colab Notebooks/Machine Learning/iris.csv', skiprows=1, delimiter=',')
sns.pairplot(data_)

在此处输入图像描述

I was wondering how could give it color, like in this image.我想知道如何给它颜色,就像这张图片一样。

在此处输入图像描述

Also I was wondering if is there some way to see my plot matrix from Matplotlib, without make my own one by one.另外我想知道是否有某种方法可以从 Matplotlib 中查看我的 plot 矩阵,而无需一一制作。 Thanks a lot!非常感谢!

Updated:更新:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2645             try:
-> 2646                 return self._engine.get_loc(key)
   2647             except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'variety'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
4 frames
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2646                 return self._engine.get_loc(key)
   2647             except KeyError:
-> 2648                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2649         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
   2650         if indexer.ndim > 1 or indexer.size > 1:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'variety'

You can just do hue='species' :你可以做hue='species'

sns.pairplot(data_, hue='species')

Output: Output:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM