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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:49:20+00:00 2026-06-10T12:49:20+00:00

I have a good one. I’ve thinking about this a long time now. I

  • 0

I have a good one. I’ve thinking about this a long time now. I have this data set and this data set could be be huge. I would like to graph a ggplot stack bar based on top 5 higest count for each month. For example, for 1//1/2012, the higest counts would be I, G, F, D and E.

df

Date    Desc    count
1/1/2012    A   10
1/1/2012    B   5
1/1/2012    C   7
1/1/2012    D   25
1/1/2012    E   19
1/1/2012    F   30
1/1/2012    G   50
1/1/2012    H   10
1/1/2012    I   100
2/1/2012    A   10
2/1/2012    B   5
2/1/2012    C   7
2/1/2012    D   25
2/1/2012    E   19
2/1/2012    F   30
2/1/2012    G   50
2/1/2012    H   10
2/1/2012    I   100
3/1/2012    A   1
3/1/2012    B   4
3/1/2012    C   5
3/1/2012    D   6
3/1/2012    E   6
3/1/2012    F   7
3/1/2012    G   8
3/1/2012    H   5
3/1/2012    I   10

I have something like this but this graphs all of the values:

 ggplot(df, aes(Date, count))+ geom_bar(aes(fill=Desc), stat="identity", position="stack") + theme_bw()
  • 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-06-10T12:49:22+00:00Added an answer on June 10, 2026 at 12:49 pm

    You have to subset the data first:

    library(plyr)
    library(ggplot2)
    df_top <- ddply(df, .(Date), 
                    function(x) head(x[order(x$count, decreasing = TRUE),], 5))
    ggplot(df_top, aes(Date, count))+ 
      geom_bar(aes(fill=Desc), stat="identity", position="stack") + 
      theme_bw()
    

    enter image description here

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

Sidebar

Related Questions

IS this straightforward? Does any one have any good examples? All my google searches
So, one problem pattern that I keep coming across and don't have a good
Is it good practice to have one shared SqlConnection object in a .NET application
Anyone have a suggestion for a good utility class that maps values from one
Good Morning. I have two tables, and one references the other. When I insert
I am writing my own blog (every one should, it's good experience). I have
Can I have good example or code about how to use Ajax Datepicker in
I have been developing a java application. Now I have decided to convert this
I usually do not have difficulty to read JavaScript code but for this one
I know this question is like one posed before, but I need a good

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.