I have a data that gives the mean
and SD:
#info mean sd
info1 20.84 4.56
info2 29.18 5.41
info3 38.90 6.22
Actually there are more than 100 lines of this.
How can I plot normal distributions for each one of the line in one figure
given the above data?
Depending on how large N truly gets, you may want to split this up over a set of multiple charts. But, here’s the basic approach. First, you need to generate some random data according to your mean and sd. I chose 1000 random points, you can adjust as necessary. Next, set up a blank plot with the appropriate dimensions, then use
linesanddensityto add the data. I used a for loop because it provided a nice way to specify the linetype for each data point. Finally, add a legend at the end:Or, use ggplot2 which can have lots of benefits, namely it will specify reasonable xlim and ylim values for you automagically, and do sensible things with the legend without much fuss.