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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:31:27+00:00 2026-06-15T17:31:27+00:00

I am running into problems with these 2 requirements: y-axis must start at 3

  • 0

I am running into problems with these 2 requirements:

  • y-axis must start at 3
  • some geom_text will range out of chart on the right

enter image description here

My ideas so far and their flaws:

  • subtract -3 from all datasets and fake y-axis labels (would prefer not to)
  • build a dummy geom_bar of height 3 (how to keep it out of legend?)

Any ideas would be appreciated!

library(grid)
library(ggplot2)

df=data.frame(
  Date=c("2012-11-30", "2012-12-03", "2012-12-04"),
  d1=c(12, 8, 13),
  d2=c(13, 7, 12),
  e1=c(7, 9, 8)
)

frame()
p=ggplot(df, aes(Date)) + 
    geom_bar(aes(y=e1, fill="e1"), stat="identity", color="red") +
    geom_line(aes(y=d1, group=1, color="d1")) +
    geom_line(aes(y=d2, group=1, color="d2")) +
    geom_text(aes(x =3.5, y=c(14,13,12), label=c("Text1","Text2","Text3"))) +
    scale_colour_manual(" ", values=c("e1"="red", "d1"="blue", "d2"="black"))+
    scale_fill_manual("", values="red") +
    coord_cartesian(ylim=c(3,15), xlim=c(0.5,3.5)) +
    theme(legend.key=element_blank(),legend.title=element_blank(),
          legend.position="top", legend.box="horizontal",
          plot.margin=unit(c(1, 2, 1, 1), "cm"))

p1 <- ggplot_gtable(ggplot_build(p))
p1$layout$clip[p1$layout$name=="panel"] <- "off"
grid.draw(p1)
  • 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-15T17:31:28+00:00Added an answer on June 15, 2026 at 5:31 pm

    you define your own scale transformation

    library(scales)
    translate3_trans <- function() {
      trans <- function(x) x - 3
      inv   <- function(x) x + 3
      trans_new("translate3_trans", trans, inv)
    }      
    

    then you add

           p <- p + scale_y_continuous(trans="translate3")
    

    enter image description here

    I don’t understand where do you want to put the geom_text exactly.

    PS : Sorry , I change the alpha to 0.5 because your red hurts my eyes.

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

Sidebar

Related Questions

I am running into problems where some of our data stores are seeing a
I'm running into some problems using my .NET 4.0 libraries in .NET 2.0 applications.
I am working on a custom SSO solution and running into some problems with
I have been trying to learn Erlang and have been running into some problems
I am running into problems when I try to run the jar file created
I'm running into problems implementing statuses for a model. This is probably due to
I'm running into problems with my Sieve of Eratosthenes. I wanted to write a
I am a Symfony2 newbie running into problems with edit-forms and doctrine. I seem
I'm new to parallel computing and am running into problems with server/client connections. I
Hi guys I'm trying to integrate the tinymce plugin however I'm running into problems

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.