Tuesday, October 22, 2019

R: How to join multiple plots into one plot?




I have two density distribution data A and B, I want to plot the two density curves into one plot. I used the following codes:



plot(user.dens.tas, col="red", xlim=c(0,0.003))
plot(item.dens.tas, col="blue", xlim=c(0,0.003))


How can I plot the two curves into one plot (combine them)?



enter image description here



Answer



plot(user.dens.tas, col="red", xlim=c(0,0.003))
lines(item.dens.tas, col="blue", xlim=c(0,0.003))


Puts one line in read, the other in blue on the same plot. You might also consider adding a title and other presentation niceties.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...