I've got a set with >10000 integers attaining values between 1 and 500. I want to plot the values in form of a histogram, however, since only a few integers attain values greater than 200, I want to use a logarithmic scale for the y-axis.
A problem emerges, when one bin has a count of zero, since the logarithmic value goes to -infinity.
To avoid this, I want to add a pseudocount of 1 to each bin. In a standard hist()-plot I can do this like follows:
hist.data = hist(data, plot=F, breaks=30)
hist.data$counts = log10(hist.data$counts + 1)
plot(hist.data, ...)
However, I struggle to find a way to access the counts in ggplot.
Is there a simple way to do this, or are there other recommended ways to deal with this problem?