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 7535397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:17:37+00:00 2026-05-30T06:17:37+00:00

I am trying to generate a histogram of below data (Data comes from a

  • 0

I am trying to generate a histogram of below data (Data comes from a sqlserver database)

    > head(Data)
     value temp
1 47.34848   97
2 45.95588   97
3 47.34848   97
4 46.99248   97
5 46.64179   97
6 46.29630   97

I tried qplot in ggplot with dodging. I was hoping i will get multiple histogram, but i got a single histogramenter image description here

> qplot(value, data=Data, geom = "bar", fill = temp, position = "dodge")

To verify that i have two different temperatures in Data, i generated a histogram of temp

> qplot(temp,data=Data,geom="bar")

enter image description here

I also generated a histogram of the value and it is same as the first plot above.
To verify my commands, i generated a graph with some sample data and the command i am using seems to be ok

    > head(SampleData)
  val cat
1   1   a
2   2   a
3   3   a
4   4   a
5   4   a
6   2   a

enter image description here

Please help me find the issue

  • 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-30T06:17:38+00:00Added an answer on May 30, 2026 at 6:17 am

    The variable used to define the two groups should be a factor.

    # Sample data
    n <- 100
    d <- sample( c(TRUE,FALSE), n, replace=TRUE )
    d <- data.frame(
      value = ifelse(d, 10, 30 ) + 10 * rnorm(n),
      temp = ifelse(d,0,97)
    )
    
    # Make sure temp is a factor
    p <- ggplot(d, aes(x=value, fill=factor(temp))) 
    
    p + geom_histogram(position="stack") 
    p + geom_histogram(position="dodge") 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a pdf file from data in a database using JasperReports
While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal
I'm trying to generate customized xml files from a template xml file in python.
I'm trying to generate a multi level nested html list from xml/xsl. For example,
I am trying to generate a schema from this xml file: http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?rettype=xml&retmode=xml&db=nucleotide&id=AB573763 I store
I'm trying to generate NHibernate mappings with ActiveRecord. I can create classes from a
I am trying to generate C# code from an XSD using xsd.exe Here is
while trying to generate a proxy from this WebService (http://scdemo14.infor.com:9014/axis/services/wb:wsclocks-inbound?wsdl) I'm receiving this error
I am trying to generate script for my sql local database created using visual
Trying to generate currency type seed data for an application and iterating through the

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.