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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:45:16+00:00 2026-05-27T00:45:16+00:00

I am graphing some data with ggplot. However, I don’t understand the error I’m

  • 0

I am graphing some data with ggplot. However, I don’t understand the error I’m getting with slightly different data than data that I can graph successfully. For example, this data graphs successfully:

to_graph <- structure(list(Teacher = c("BS", "BS", "FA"
), Level = structure(c(2L, 1L, 1L), .Label = c("BE", "AE", "ME", 
"EE"), class = "factor"), Count = c(2L, 25L, 28L)), .Names = c("Teacher", 
"Level", "Count"), row.names = c(NA, 3L), class = "data.frame")

ggplot(data=to_graph, aes(x=Teacher, y=Count, fill=Level), ordered=TRUE) +
       geom_bar(aes(fill = Level), position = 'fill') +
       scale_y_continuous("",formatter="percent") +
       scale_fill_manual(values = c("#FF0000", "#FFFF00","#00CC00", "#0000FF")) +
       opts(axis.text.x=theme_text(angle=45)) + 
       opts(title = "Score Distribution")

But this does not:

to_graph <- structure(list(School = c(84351L, 84384L, 84385L, 84386L, 84387L, 
84388L, 84389L, 84397L, 84398L, 84351L, 84384L, 84385L, 84386L, 
84387L, 84388L, 84389L, 84397L, 84398L, 84351L, 84386L), Level = structure(c(2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 3L, 3L), .Label = c("BE", "AE", "ME", "EE"), class = "factor"), 
    Count = c(3L, 7L, 5L, 4L, 3L, 4L, 4L, 6L, 2L, 116L, 138L, 
    147L, 83L, 76L, 81L, 83L, 85L, 53L, 1L, 1L)), .Names = c("School", 
"Level", "Count"), row.names = c(NA, 20L), class = "data.frame")

ggplot(data=to_graph, aes(x=School, y=Count, fill=Level), ordered=TRUE) +
       geom_bar(aes(fill = Level), position = 'fill') +
       scale_y_continuous("",formatter="percent") +
       scale_fill_manual(values = c("#FF0000", "#FFFF00","#00CC00", "#0000FF")) +
       opts(axis.text.x=theme_text(angle=90)) + 
       opts(title = "Score Distribution")

With the latter code, I get this error:

stat_bin: binwidth defaulted to range/30. Use ‘binwidth = x’ to adjust
this. Error in if (!all(data$ymin == 0)) warning(“Filling not well
defined when ymin != 0”) : missing value where TRUE/FALSE needed

Anyone know what’s going on here? Thank you!

  • 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-27T00:45:16+00:00Added an answer on May 27, 2026 at 12:45 am

    The error occurs because your x variable has numerical values, when in reality you want them to be discrete, i.e. use x=factor(School).

    The reason for this is that stat_bin, the default stat for geom_bar, will try to summarise for each unique value of x. When your x-variable is numeric, it tries to summarise at each integer in the range. This is clearly not what you need.

    ggplot(data=to_graph, aes(x=factor(School), y=Count, fill=Level), ordered=TRUE) + 
        geom_bar(aes(fill = Level), position='fill') + 
        opts(axis.text.x=theme_text(angle=90)) + 
        scale_y_continuous("",formatter="percent") + 
        opts(title = "Score Distribution") + 
        scale_fill_manual(values = c("#FF0000", "#FFFF00","#00CC00", "#0000FF"))
    

    enter image description here

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

Sidebar

Related Questions

I am thinking of using wxMathPlot for plotting/graphing some data that arrives continuously. I
Looking at adding some data graphing to a new iPhone app in development (ala
I've created a graphing application that calls a web service. The user can zoom
I need help programatically graphing more points than can fit in a single Excel
What graphing algorithm library do people recommend for java that can do the following:
Needing some guidance about how to properly graph data that is very small and
I am searching for a good graphing utility that can export graphs 100% server
I am looking for some sort of a free JavaScript/JQuery graphing library that has
I'm trying to use Raphael.js to do some nice graphing for data after which
I am looking for a graphing library that I can use in a C#

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.