Here is a question for R-users. I am interested in drawing a histogram with points stacked up, instead of a bar. For example if the data is (1,1,2,1,2,3,3,3,4,4), then I would like to see three points stacked up at 1, 2 points stacked up at 2 and so on. What is the best way to do this in R?
Histograms visualize quantitative data or numerical data, whereas bar charts display categorical variables. In most instances, the numerical data in a histogram will be continuous (having infinite values). Attempting to display all possible values of a continuous variable along an axis would be foolish.
Histograms and bar charts can both display large sets of data. However, bar charts display categorical data, or information that's separated into different groups based on characteristics, while histograms display numerical or quantitative data in bins, which is data that you can measure with numbers.
You can do this yourself pretty quickly:
x <- c(1,1,2,1,2,3,3,3,4,4)
plot(sort(x), sequence(table(x)))
The simplest answer I know is this:
x <- c(1,1,2,1,2,3,3,3,4,4)
stripchart(x,method="stack",at=0)
It's better than Jonathan Chang's suggestion because stripchart
does proper stacking of points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With