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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:53:39+00:00 2026-05-16T05:53:39+00:00

I’ve been learning ggplot in the last few weeks. Generally, I’m getting things done

  • 0

I’ve been learning ggplot in the last few weeks. Generally, I’m getting things done (slowly though), but now I’m stuck. I created the following facetted plot: http://dl.dropbox.com/u/7752237/example_bad_y_scales.pdf

Faceting is done by

pl <- pl + facet_wrap(~sci_name,ncol=1,scale="free")

The Problem: Numbers on the y-scale don’t look good, especially the scales that go from 0-70 (numbers overlapping).
I’d like the somehow change the number of breaks on the y-scale (to let’s say just 1 or 2 breaks). Does anybody maybe have an idea how to do that? Any help would be very much appreciated. 🙂

PS: I didn’t include a minimal example because I think it wouldn’t help much to solve that specific problem.

Edit after Kohskes answer:

Hi Kohske,
Wow, that was a really fast answer, thanks! However, I think it doesn’t work well with facetted plots. Look at

p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point()
p <- p + facet_wrap(~gear,ncol=1,scale="free")

On the y-scale, it gives 3 breaks in the middle plot and 8 breaks in the lower plot… not very consistent (but at least not overlapping as in my example).

p2 <- p + scale_y_continuous(breaks=c(15,30),minor_breaks=c(10,20,25))

isn’t really good neither: two major ticks on lower plots, only one in middle and upper plot.
When having scales with bigger differences than in mtcars, the result would be even less satisfying. Any other ideas? 😉

Edit after Kohskes edit:

Hi, I can’t see how to implement this. Searching for ggplot and input_break on google yielded only 10 results, none of them did help.
I tried

p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point()
p <- p + facet_wrap(~gear,ncol=1,scale="free")
p$input_breaks<-function(., range) {
    pretty(range, n=3)
}
print(p)

However, I can’t see any effects in the graph (tried for n=1, 3, 15). Could you describe how to implement this on the mtcars example? Thanks!

  • 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-16T05:53:40+00:00Added an answer on May 16, 2026 at 5:53 am

    p <- ggplot(mtcars, aes(wt, mpg))
    p <- p + geom_point()

    dev.new(height=1)
    print(p)
    dev.new(height=1)
    p <- p + scale_y_continuous(breaks=c(15,30),minor_breaks=c(10,20,25))
    print(p)
    

    the trick is scale_y_continuous and you can specify the breaks and minor breaks in it.

    edited:

    probably you cannot specify the breaks separately for each facet.
    one workaround is to control the prettiness of the breaks by:

    Trans$input_breaks<-function(., range) {
        pretty(range, n=3)
    }
    print(p)
    

    changing the “n=3” yields different prettiness.

    edited again:

    here is full example:

    library(ggplot2)
    p <- ggplot(mtcars, aes(wt, mpg))+geom_point()
    Trans$input_breaks<-function(., range) {
        pretty(range, n=100)
    }
    print(p)
    

    in this case, probably you can see a hundred of ticks.
    by changing n=100, you can custom it.

    note that this has side-effect. all plots after this has same number of ticks, and also x and y axis have the same number of ticks.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I

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.