seaborn pairplot不适用于单个图形

2024-09-23 14:11:31 发布

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

我有一种奇怪的行为,seaborn会像预期的那样绘制不同的图形,但无法在单个图形中显示数据

我使用的是anaconda3和visualstudio(在jupyter中也是这个问题)

seaborn is v0.11.0
matplotlib is v3.3.1
anaconda3 is v1.9.12
python is v3.8.3
MSC is v.1916 64 bit

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.pairplot(x_vars=["tip"], y_vars=["size"], 
            data=tips)
sns.pairplot(tips)
plt.show()

输出如下所示:

output for sns.pairplot(x_vars=["tip"], y_vars=["size"],data=tips)

output for sns.pairplot(tips)

数据似乎很清楚,但在前一句话中不知何故不是plottet

编辑:这似乎是一个库版本问题

这些可能是图书馆版本:

# Name                    Version                   Build  Channel
attrs                     20.2.0                     py_0
backcall                  0.2.0                      py_0
blas                      1.0                         mkl
bzip2                     1.0.8                he774522_0
ca-certificates           2020.7.22                     0
certifi                   2020.6.20                py38_0
cfitsio                   3.470                he774522_6
click                     7.1.2                      py_0
click-plugins             1.1.1                      py_0
cligj                     0.5.0                    py38_0
colorama                  0.4.3                      py_0
curl                      7.67.0               h2a8f88b_0
cycler                    0.10.0                   py38_0
decorator                 4.4.2                      py_0
expat                     2.2.9                h33f27b4_2
fiona                     1.8.13.post1     py38hd760492_0
freetype                  2.10.2               hd328e21_0
freexl                    1.0.5                hfa6e2cd_0
gdal                      3.0.2            py38hdf43c64_0
geopandas                 0.8.1                      py_0
geos                      3.8.0                h33f27b4_0
geotiff                   1.5.1                h5770a2b_1
hdf4                      4.2.13               h712560f_2
hdf5                      1.10.4               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha925a31_3
intel-openmp              2020.2                      254
ipykernel                 5.3.4            py38h5ca1d4c_0
ipython                   7.18.1           py38h5ca1d4c_0
ipython_genutils          0.2.0                    py38_0
jedi                      0.17.2                   py38_0
joblib                    0.16.0                     py_0
jpeg                      9b                   hb83a4c4_2
jupyter_client            6.1.7                      py_0
jupyter_core              4.6.3                    py38_0
kealib                    1.4.7                h07cbb95_6
kiwisolver                1.2.0            py38h74a9793_0
krb5                      1.16.4               hc04afaa_0
libboost                  1.67.0               hd9e427e_4
libcurl                   7.67.0               h2a8f88b_0
libgdal                   3.0.2                h1155b67_0
libiconv                  1.15                 h1df5818_7
libkml                    1.3.0                he5f2a48_4
libnetcdf                 4.6.1                h411e497_2
libpng                    1.6.37               h2a8f88b_0
libpq                     11.2                 h3235a2c_0
libsodium                 1.0.18               h62dcd97_0
libspatialindex           1.9.3                h33f27b4_0
libspatialite             4.3.0a               h7ffb84d_0
libssh2                   1.9.0                h7a1dbc1_1
libtiff                   4.1.0                h56a325e_0
libxml2                   2.9.10               h464c3ec_1
lz4-c                     1.8.1.2              h2fa13f4_0
m2w64-expat               2.1.1                         2
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gettext             0.19.7                        2
m2w64-gmp                 6.1.0                         2
m2w64-libiconv            1.14                          6
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
m2w64-xz                  5.2.2                         2
matplotlib                3.3.1                         0
matplotlib-base           3.3.1            py38hba9282a_0
mkl                       2020.2                      256
mkl-service               2.3.0            py38hb782905_0
mkl_fft                   1.2.0            py38h45dec08_0
mkl_random                1.1.1            py38h47e9c7a_0
msys2-conda-epoch         20160418                      1
munch                     2.5.0                      py_0
numpy                     1.19.1           py38h5510c5b_0
numpy-base                1.19.1           py38ha3acd2a_0
olefile                   0.46                       py_0
openjpeg                  2.3.0                h5ec785f_1
openssl                   1.1.1h               he774522_0
pandas                    1.1.1            py38ha925a31_0
parso                     0.7.0                      py_0
pcre                      8.44                 ha925a31_0
pickleshare               0.7.5                 py38_1000
pillow                    7.2.0            py38hcc1f983_0
pip                       20.2.2                   py38_0
postgresql                11.2                 h3235a2c_0
proj                      6.2.1                h9f7ef89_0
prompt-toolkit            3.0.7                      py_0
pygments                  2.7.1                      py_0
pyparsing                 2.4.7                      py_0
pyproj                    2.6.1.post1      py38hcfa1391_1
pyqt                      5.9.2            py38ha925a31_4
python                    3.8.5                h5fd99cc_1
python-dateutil           2.8.1                      py_0
pytz                      2020.1                     py_0
pywin32                   227              py38he774522_1
pyzmq                     19.0.2           py38ha925a31_1
qt                        5.9.7            vc14h73c81de_0
rtree                     0.9.4            py38h21ff451_1
scikit-learn              0.23.2           py38h47e9c7a_0
scipy                     1.5.0            py38h9439919_0
seaborn                   0.11.0                     py_0
setuptools                49.6.0                   py38_1
shapely                   1.7.1            py38h210f175_0
sip                       4.19.13          py38ha925a31_0
six                       1.15.0                     py_0
sqlite                    3.33.0               h2a8f88b_0
tbb                       2018.0.5             he980bc4_0
threadpoolctl             2.1.0              pyh5ca1d4c_0
tiledb                    1.6.3                h7b000aa_0
tk                        8.6.10               he774522_0
tornado                   6.0.4            py38he774522_1
traitlets                 5.0.4                      py_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_3
wcwidth                   0.2.5                      py_0
wheel                     0.35.1                     py_0
wincertstore              0.2                      py38_0
xerces-c                  3.2.3                ha925a31_0
xz                        5.2.5                h62dcd97_0
zeromq                    4.3.2                ha925a31_3
zlib                      1.2.11               h62dcd97_4
zstd                      1.3.7                h508b16e_0

Tags: pymatplotlibisvarsseabornsnstipsmkl
1条回答
网友
1楼 · 发布于 2024-09-23 14:11:31

我认为matplotlib3.3.1或seaborn0.11.0中都有一个bug。我检查了给定的环境,并给出了一个带有sns.pairplot(x_vars=["tip"], y_vars=["size"],data=tips)的空白图

解决方案: 将matplotlib版本更改为3.2.1,将seaborn版本更改为0.10.1。它在给定版本中对我有效

如果您使用yml文件创建conda环境,请在.yml文件中使用以下内容

name: test
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.8
  - seaborn=0.10.1
  - matplotlib=3.2.1

相关问题 更多 >