Using the data in this question https://stackoverflow.com/questions/21663108/coloring-points-on-a-lattice-plot-in-r I want to use the histogram
function in lattice
to plot the three histograms on the same plot but separately so that I can control the colors and allow for a semi-transparent color where the histograms overlap.
However, the following code doesn't work:
histogram(locs[locs.col=="darkblue"] , breaks=20, xlim=c(25,150),col="darkblue" )
histogram(locs[locs.col=="yellow"] , breeaks=20, xlim=c(25,150),col="yellow",add=T ) # add doesn't work here
histogram(locsy[locs.col=="red"] , breaks=20, xlim=c(25,150),col="red",add=T )
because the histograms won't be added to eachother. I know this works for the hist
function in base packages so here are my questions:
1) Is there a way of adding histograms to the plot with histogram
?
2) How can I make the bins of the histograms to be the same width for each instance of a histogram
3) How can I make the colors semi-transparent for where the histograms overlap?
4) How can I rotate the histogram 90 degrees so that it frequency is the horizontal axis?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…