【问题标题】:How to remove label name from count plot graphic in Seaborn?如何从 Seaborn 的计数图中删除标签名称?
【发布时间】:2021-01-02 16:37:45
【问题描述】:

主要问题是如果我有三个数据集文件的计数图,如何删除图形中的“标签”命名空间?我正在使用 Seaborn 模块。

#Importing the libraries
 import pandas as pd
 import numpy as np
 import seaborn as sb

#Reading the files 
train_filename = 'train.csv'
test_filename = 'test.csv'
valid_filename = 'valid.csv'

train_news = pd.read_csv(train_filename)
test_news = pd.read_csv(test_filename)
valid_news = pd.read_csv(valid_filename)

#Data observation
 def data_obs():
     print("Training dataset size:")
     print(train_news.shape)
     print(train_news)

     print("Testing dataset size:")
     print(test_news.shape)
     print(test_news)

     print("Validation dataset size:")
     print(valid_news.shape)
     print(valid_news)

  print(data_obs())

这是我从数据enter image description here得到的结果

另外,我正在使用 LIAR 数据集,它具有以下功能: enter image description here

【问题讨论】:

  • 你在使用 seaborn 吗?
  • 是的,我正在使用 seaborn
  • 请包含其余代码
  • 您好,欢迎来到 Stack。有几件事,首先将代码作为文本而不是图像。其次,显示您的数据,因为我认为问题在于您加载的内容和方式,但无法检查。最后,很高兴看到您希望它的外观。

标签: python matplotlib machine-learning count namespaces


【解决方案1】:

应该这样做:

g = sb.countplot(x='Label', data=dataFile, palette="hls")

g.set(xticklabels=[])   # To remove the ticklabels
g.set(xlabel=None)      # To remove the "Label"

【讨论】:

  • 我不认为这是问题所在,我认为 ma_brr124 表示空列...
【解决方案2】:

我进行了测试,发现当我只打印训练和测试数据时,我得到了正确的图表,但是当我添加验证数据时,它显示了一个名为“标签”的额外空列

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-16
    • 2018-09-13
    • 2014-07-12
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多