Types Of Plots for Discrete Data

So I have a lot of discrete variables in my dataset and want to visualize them (univariate for now). I went through various articles over the internet and it is suggested that histograms and count plots are apt choices for plotting discrete data. Many of the discrete variables in my dataset have 500+ unique discrete values and when I plot them on a histogram it is taking a lot of time to show my any output. So is my approach correct?, can we actually plot these many unique valued discrete variables using a histogram? or do you suggest any other type of plot for the same?

Edit : Just got the output for a variable with 400+ discrete values and the histogram (sns.histplot) is empty, the x and y axis are visible but there are no bars in the histogram. Why would that be?

I have attached a reference photo of my column with the value_counts() function's output. There are about 400 discrete values

Topic matplotlib python-3.x seaborn machine-learning

Category Data Science


[completely edited after clarification from OP]

A histogram is built by making bins of equal size across the range of values taken by the variable. For example if the variable ranges from 0 to 500 one might decide to create 50 bins of size 10. Then the actual values of the distribution are counted by bin: every value between 0 and 9 goes into the first bin, every value between 10 and 19 goes into the second bin etc.

The number of discrete values does not matter (in fact the values can be continuous) because the values are binned, i.e. they are grouped by how close they are to each other (with arbitrary interval bounds).

I can see that the data you have is already formatted as

<value> <frequency>

The problem you have certainly comes from the fact that this format is incorrect for the function: typically histogram functions create the bins themselves, so there's no need to have counted the values beforehand. This means that you should provide a single vector containing all the values as many times as they occur.

Alternatively you could create the bins yourself beforehand: decide the intervals then count how many values in each bin. Then use a simple bar plot to show the count for every bin. This option is usually less convenient.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.