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

  • SEARCH
  • Home
  • 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 6880155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:56:17+00:00 2026-05-27T04:56:17+00:00

I am venturing babysteps in ggplots and need some help with the following problem!

  • 0

I am venturing babysteps in ggplots and need some help with the following problem!
I have a dataframe called dftemp which has the following structure

   Year Month Values
1   1996   Jan      0
2   1996   Feb      0
3   1996   Mar      0
4   1996   Apr      0
5   1996   May      0
6   1996   Jun      0
7   1996   Jul      0
8   1996   Aug      0
9   1996   Sep      0
10  1996   Oct      0
11  1996   Nov      0
12  1996   Dec      0

This goes on like this until:

181 2011   Jan     -3
182 2011   Feb      2
183 2011   Mar      2
184 2011   Apr      6
185 2011   May    -13
186 2011   Jun     -4
187 2011   Jul      0
188 2011   Aug      0
189 2011   Sep      0
190 2011   Oct     -7
191 2011   Nov     -7
192 2011   Dec      0

I tried to make a barchart by:

ggplot(dftemp,aes(x=Month,y=Values,fill=Year))+geom_bar(binwidth=10)

And got something weird and wrong (sadly my reputation is not high enough so I cannot post the image)..The resulting plot had y-values that were squished together very tightly by the bottom of the y-axis..

I don’t understand what I am doing wrong here! I tried putting factor() in front of the aes inputs but to no avail!

  • 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-27T04:56:18+00:00Added an answer on May 27, 2026 at 4:56 am

    Your first challenge is to use the stat=”identity” argument in your geom_bar

    It is not clear what you are trying to plot, or how you plan to combine your data, so I’ll offer a few options.

    First let’s rebuild your data for use:

    library(chron)
    tt = seq(chron("1/1/1996"),chron("12/31/2011"),by="months")
    dftemp = as.data.frame()
    dftemp$datestamps = tt
    dftemp$years = years(tt)
    dftemp$months = months(tt)
    dftemp$values = round(runif(length(tt),-15,15))
    

    Here is a simple bar plot, one bar for each date stamp:

    ggplot(dftemp,aes(x=datestamps,y=values))+geom_bar(stat="identity",position="dodge")
    

    One bar per month, stacked

    ggplot(dftemp,aes(x=months,y=values))+geom_bar(stat="identity")
    

    One bar per year, stacked

    ggplot(dftemp,aes(x=years,y=values))+geom_bar(stat="identity")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started venturing into some HP webOS development and I am wondering
I'm venturing to read a code in Perl and found the following regular expressions:
Some background.... We're venturing into Azure for the first time and are trying to
I'm venturing into the world of asp.net mvc. I have not yet understood whether
Having some experiences with iOS. I now look venturing into Android devices. One of
I am venturing into WPF - first time in (VB).NET - and trying to
If you had a differential of either venturing into Delphi land or Qt land
I'm venturing into making my VB.NET application a little better to use by making
I'm venturing into the world of C++ and Linux, and am having problems linking
I'm venturing out of the world of .NET and into the world of open-source.

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.