Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:31:28+00:00 2026-05-24T06:31:28+00:00

I am new to R and am trying to plot 3 histograms onto the

  • 0

I am new to R and am trying to plot 3 histograms onto the same graph.
Everything worked fine, but my problem is that you don’t see where 2 histograms overlap – they look rather cut off.

When I make density plots, it looks perfect: each curve is surrounded by a black frame line, and colours look different where curves overlap.

Can someone tell me if something similar can be achieved with the histograms in the 1st picture? This is the code I’m using:

lowf0 <-read.csv (....)
mediumf0 <-read.csv (....)
highf0 <-read.csv(....)
lowf0$utt<-'low f0'
mediumf0$utt<-'medium f0'
highf0$utt<-'high f0'
histogram<-rbind(lowf0,mediumf0,highf0)
ggplot(histogram, aes(f0, fill = utt)) + geom_histogram(alpha = 0.2)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:31:28+00:00Added an answer on May 24, 2026 at 6:31 am

    Your current code:

    ggplot(histogram, aes(f0, fill = utt)) + geom_histogram(alpha = 0.2)
    

    is telling ggplot to construct one histogram using all the values in f0 and then color the bars of this single histogram according to the variable utt.

    What you want instead is to create three separate histograms, with alpha blending so that they are visible through each other. So you probably want to use three separate calls to geom_histogram, where each one gets it’s own data frame and fill:

    ggplot(histogram, aes(f0)) + 
        geom_histogram(data = lowf0, fill = "red", alpha = 0.2) + 
        geom_histogram(data = mediumf0, fill = "blue", alpha = 0.2) +
        geom_histogram(data = highf0, fill = "green", alpha = 0.2) +
    

    Here’s a concrete example with some output:

    dat <- data.frame(xx = c(runif(100,20,50),runif(100,40,80),runif(100,0,30)),yy = rep(letters[1:3],each = 100))
    
    ggplot(dat,aes(x=xx)) + 
        geom_histogram(data=subset(dat,yy == 'a'),fill = "red", alpha = 0.2) +
        geom_histogram(data=subset(dat,yy == 'b'),fill = "blue", alpha = 0.2) +
        geom_histogram(data=subset(dat,yy == 'c'),fill = "green", alpha = 0.2)
    

    which produces something like this:

    enter image description here

    Edited to fix typos; you wanted fill, not colour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, this may have been answered, but I'm new and trying to learn, so
http://lakefrontmotorlodge.co.nz/new/ I am trying to get the background to fade smoothly, but it fades
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to create a new Dedicated Cache Role in Windows Azure but get the
I am trying to plot roots of a function that is composed of multiple
I'm very new to python. two days. trying to get a plot working with
I'm (trying to) using JSON with PHP. I want to plot a graph using
I'm trying to implement some sort of 'just-for-me' game engine and the problem's plot
I was trying to use ggplot to plot monthly data that looks like this
I'm really new to web developing...I'm trying to draw area graph on JSP (this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.