0
$\begingroup$

I have used in the past a seaborn plotting function to visualize the number of samples belonging to each class directory. That was very easy since each directory in which the dataset was divided represented a class, and within each directory there was a given number of samples. I visualized in pytorch the samples distribution in the classes or categories by this simple code :

import seaborn as sns
sns.countplot(x = train_dataset.targets)
plt.show()

The result of this code was the following visualization plot:

enter image description here

As you see the number of classes (=directories) was 25.

But now I need to visualize the same data structure with a larger number of directories. Actually about 1600 directories (or classes). Unfortunately I realized the I could not use the same piece of code because the result was the following :

enter image description here

What modification should I add to the code in order to make readable the visualization ? Thank you for you help

$\endgroup$

1 Answer 1

1
$\begingroup$

If your question is specifically about how to make the values on the x-axis legible, you can modify your code as follows:

import seaborn as sns

myplot = sns.countplot(x = train_dataset)

# 200 is an arbitrary number representing the spacing between x-ticks
myplot.set_xticks(range(0, num_classes, 200)) 
                                           
plt.show()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.