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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:42:44+00:00 2026-06-01T17:42:44+00:00

In Adding individual arrows in multiple plots I described a problem which has been

  • 0

In
Adding individual arrows in multiple plots
I described a problem which has been resolved thanks to mathematical.coffee.

My problem was how to add a single arrow to only one facet. Recently I installed a new version of R:

platform i386-pc-mingw32
version.string R version 2.14.2 (2012-02-29) ggplot2_0.9.0

Here is the code example

# data frame
xdf <- data.frame(x=rep(1:10,2)
                  ,y=c( 2*c(1:10)+rnorm(10,0,3), 4*c(1:10)+rnorm(10,0,5))
                  ,z=rep(c("A","B"),each=10)
                  )
xdf

# plot
ggplot with faceting
xp <- ggplot(xdf,aes(x=x,y=y)) +
   geom_line() +
   facet_grid(. ~ z)
xp

# location of the arrow: x=4, y=y+1 on the top of the first facet (A)
(f1x4 <- xdf[4,"y"]+1)

# add arrow and label
xp + geom_segment(aes(x=4,xend=4,y=f1x4+3,yend=f1x4,z='A')  # <-- see the z='A'
                  , arrow=arrow(length=unit(0.4,"cm")
                    )
                 ) +
  geom_text(aes(x=4,y=f1x4+5, label="a",z='A'))        # <-- see the z='A'

What should happen: the arrow should be created only on facet A.
What happens: the arrow is created on both facets A and B.

Has anybody an idea how to solve this problem?

  • 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-01T17:42:45+00:00Added an answer on June 1, 2026 at 5:42 pm

    Obviously there was a change after updating R and ggplot. The coordinate data have to be delivered with a data frame. Here is an example with an additional grouping:

    xdf <- data.frame(x=rep(1:10,each=4)
                  ,y=rep(1:10,each=4)*rep(1:4,10)  +rnorm(40,0,1)
                  ,g=rep(c("R","S"),20)
                  ,z=rep(c("A","A","B","B"),10)
                  )
    head(xdf)
    # plot
    xp <- ggplot(xdf,aes(x=x,y=y, group=g)) +
    geom_line() +
    facet_grid(. ~ z)
    xp
    # location of the arrow: x=4, y=y+1 on the top of the first facet (A)
    (f1x4 <- subset(xdf,x==4 & g=="R" & z=="A")$y)
    arrdf <- data.frame(x = 4, y = f1x4, z = "A", g = "R")   # create new data.frame for    annotations
    # add arrow and label
    xp + geom_segment(data=arrdf,aes(x=x,xend=x,y=y+3,yend=y,z=z,g=g)  # <-- see the z='A'
                  , arrow=arrow(length=unit(0.4,"cm")
                    )
                 ) +
    geom_text(data=arrdf,aes(x=x,y=y+4, label="a",z=z, g=g)) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on adding open graph tags to the individual pages of our wedding photography
I'm adding multi-currency support to an e-commerce application. The way I approached the problem
Recently we have been adding automated tests to our existing java applications. What we
I am adding a right click functionality on individual nodes of a treeView in
I’m refactoring some code and adding a method which will replace a (soon-to-be) deprecated
Our application has over 15 different top-level mxml files to create individual controls that
I followed the tutorial here to add an inforwindow to the individual clusters of
Adding more than one child to a WPF StatusBar results in poor layout with
Adding Exceptional Handling is a good practise, but I have a doubt, In our
Adding the row one by one in the button click.. (i tried but its

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.