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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:16:17+00:00 2026-06-04T22:16:17+00:00

Using ggplot, is it possible to get R-style x/y axes that don’t meet at

  • 0

Using ggplot, is it possible to get “R-style” x/y axes that don’t meet at the origin and that instead consist of two disconnected ranges, as in the following example?

enter image description here

The reason here is mainly to get ggplot plots to look consistent next to pure-R ones.

  • 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-04T22:16:17+00:00Added an answer on June 4, 2026 at 10:16 pm

    Try this,

    library(ggplot2)
    
    d <- data.frame(x=1:10, y=rnorm(10))
    
    base_breaks_x <- function(x){
      b <- pretty(x)
      d <- data.frame(y=-Inf, yend=-Inf, x=min(b), xend=max(b))
      list(geom_segment(data=d, aes(x=x, y=y, xend=xend, yend=yend), inherit.aes=FALSE),
           scale_x_continuous(breaks=b))
    }
    base_breaks_y <- function(x){
      b <- pretty(x)
      d <- data.frame(x=-Inf, xend=-Inf, y=min(b), yend=max(b))
      list(geom_segment(data=d, aes(x=x, y=y, xend=xend, yend=yend), inherit.aes=FALSE),
           scale_y_continuous(breaks=b))
    }
    
    ggplot(d, aes(x,y)) +
      geom_point() +
      theme_bw() +
      theme(panel.border = element_blank(),
           panel.grid.major = element_blank(),
           panel.grid.minor = element_blank()) +
      base_breaks_x(d$x) +
      base_breaks_y(d$y)
    

    screenshot

    Edit: a related issue has since been discussed in the ggtheme package, and potentially provides a cleaner solution (no need to provide the data explicitly to the breaks function).

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

Sidebar

Related Questions

When plotting in R using ggplot, I've noticed that sometimes if you don't specify
I am making a dotplot using ggplot with the code and data that is
would like to create a function that generates graphs using ggplot. For the sake
I have generated a dendrogram using ggdendro and ggplot. I have two issues regarding
I am using ggplot to generate a chart that summarises a race made up
I have generated the following plot using the R code that follows it: ggplot(lengths,
Using the new dollar_format() syntax in ggplot, I get unexpected behavior. Is there (yet)
I started to use ggplot in order to generate some graphs. I am using
I am using ggplot2 to plot a figure that contains nine facets. Each facet
I have the following graph that I generated using ggplot2 I had finalPlot as

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.