Quantcast
Channel: How can I plot two histograms together in R? - Stack Overflow
Browsing latest articles
Browse All 10 View Live

Image may be NSFW.
Clik here to view.

Answer by Joseph Crispell for How can I plot two histograms together in R?

So many great answers but since I've just written a function (plotMultipleHistograms() in 'basicPlotteR' package) function to do this, I thought I would add another answer.The advantage of this...

View Article



Image may be NSFW.
Clik here to view.

Answer by Stat-R for How can I plot two histograms together in R?

Already beautiful answers are there, but I thought of adding this. Looks good to me.(Copied random numbers from @Dirk). library(scales) is...

View Article

Image may be NSFW.
Clik here to view.

Answer by András Aszódi for How can I plot two histograms together in R?

@Dirk Eddelbuettel: The basic idea is excellent but the code as shown can be improved. [Takes long to explain, hence a separate answer and not a comment.]The hist() function by default draws plots, so...

View Article

Image may be NSFW.
Clik here to view.

Answer by Mateo Sanchez for How can I plot two histograms together in R?

Plotly's R API might be useful for you. The graph below is here.library(plotly)#add username and keyp <- plotly(username="Username", key="API_KEY")#generate datax0 = rnorm(500)x1 =...

View Article

Image may be NSFW.
Clik here to view.

Answer by Dirk is no longer here for How can I plot two histograms together...

Here is an even simpler solution using base graphics and alpha-blending (which does not work on all graphics devices):set.seed(42)p1 <- hist(rnorm(500,4)) # centered at 4p2 <- hist(rnorm(500,6))...

View Article


Image may be NSFW.
Clik here to view.

Answer by chrisamiller for How can I plot two histograms together in R?

Here's a function I wrote that uses pseudo-transparency to represent overlapping histogramsplotOverlappingHist <- function(a, b, colors=c("white","gray20","gray50"), breaks=NULL, xlim=NULL,...

View Article

Image may be NSFW.
Clik here to view.

Answer by John for How can I plot two histograms together in R?

Here's the version like the ggplot2 one I gave only in base R. I copied some from @nullglob.generate the datacarrots <- rnorm(100000,5,2)cukes <- rnorm(50000,7,2.5)You don't need to put it into a...

View Article

Answer by nullglob for How can I plot two histograms together in R?

Here is an example of how you can do it in "classic" R graphics:## generate some random datacarrotLengths <- rnorm(1000,15,5)cucumberLengths <- rnorm(200,20,7)## calculate the histograms - don't...

View Article


Image may be NSFW.
Clik here to view.

Answer by John for How can I plot two histograms together in R?

That image you linked to was for density curves, not histograms.If you've been reading on ggplot then maybe the only thing you're missing is combining your two data frames into one long one.So, let's...

View Article


Image may be NSFW.
Clik here to view.

How can I plot two histograms together in R?

I am using R and I have two data frames: carrots and cucumbers. Each data frame has a single numeric column that lists the length of all measured carrots (total: 100k carrots) and cucumbers (total: 50k...

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images