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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:08:00+00:00 2026-06-06T14:08:00+00:00

Can I use the arrow() function in R to plot a transparent arrow between

  • 0

Can I use the arrow() function in R to plot a transparent arrow between two points that changes color? For example, an arrow that starts out as red at one point, and gradually changes to blue at the other point (both points are on the same row in a dataframe)? If so, how? And if not, is there another function that can do that in R?

Here is the piece of code I have until now, which draws points (blue and red) and connects the blue points with the red points with transparent blue arrows:

par(xpd=NA, mfrow=c(1,1), mar=c(4.25,3.2,6.20,3.55))
plot(data$x1,data$y1,col="red",pch=20,cex=0.6,xlim=c(xmin,xmax),ylim=c(ymin,ymax),axes=FALSE,ann=FALSE,xaxt='n',yaxt='n')
par(new=T)
plot(data$x2,data$y2,col="blue",pch=20,cex=0.6,xlim=c(xmin,xmax),ylim=c(ymin,ymax),axes=FALSE,ann=FALSE,xaxt='n',yaxt='n')
par(new=T)
plot(grid.picture(NLmap[-1]),xlim=c(xmin,xmax),ylim=c(ymin,ymax),axes=FALSE,ann=FALSE,xaxt='n',yaxt='n')
par(new=T)

points(data$x1,data$y1,col="red",pch=20,cex=0.25)
par(new=T)
points(data$x2,data$y2,col="blue",pch=20,cex=0.25)
par(new=T)

arrows(data$x1,data$y1, data$x2, data$y2, length = 0.05, angle = 30, 
   code = 2, col = "#9AC0CD40", lty = par("lty"), lwd = par("lwd"))

Hope this helps!

  • 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-06T14:08:02+00:00Added an answer on June 6, 2026 at 2:08 pm

    First of all, I should mention that my answer is directly derived from the information provided in the comments and the answer by DWin. I had never seen those functions before, so I thought I would give them a shot.

    I ended up creating a little function that works like arrows except a colour scale is added. I think this is essentially what you want.

    require(plotrix)
    
    color.scale.arrow = function(x1,y1,x2,y2,first.col,second.col,
    lwd= par('lwd'),lty=par('lty'),angle=30,length=0.25) {
            x=mapply(seq,x1,x2,length.out=256) # Each column is one arrow
            y=mapply(seq,y1,y2,length.out=256) # Each column is one arrow
    
            arrows(x[255,],y[255,],x[256,],y[256,],
                   col=ifelse(y[256,]<y[255,],first.col,second.col),
                   lwd=lwd,lty=lty,angle=angle,length=length)
    
            rgb1=col2rgb(first.col)[,1] / 255
            rgb2=col2rgb(second.col)[,1] / 255
            cols=rbind(rgb1,(rgb1 + rgb2) / 2,rgb2)
    
            invisible(
                  sapply(seq(ncol(x)),function(line) 
                      color.scale.lines(x[,line],y[,line],
                      cols[,'red'],cols[,'green'],cols[,'blue'],
                      lwd=lwd,lty=lty)
                  )
           )
    }
    
    # Create sample data
    set.seed(1)
    x <- runif(12); y <- rnorm(12)
    i <- order(x,y); x <- x[i]; y <- y[i]
    x1=x[s]
    x2=x[s+1]
    y1=y[s]
    y2=y[s+1]
    
    # Plot sample data
    plot(x,y, main='', type='n')
    color.scale.arrow(x1,y1,x2,y2,'red','blue',lwd=2)
    

    Sample Arrow Plot

    The arrow head will have a colour that matches the ‘end’ colour given in color.scale.arrow.

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

Sidebar

Related Questions

I'm trying to create a function that i can use over and over. I
How can the code below be modified, such that I can use the arrow
In the bash shell, I can use the up arrow key to navigate to
In shells like the interactive python shell, you can usually use the arrow keys
In arrow do notation, you can use the rec keyword to write recursive definitions.
I can use the Network tab in the Google Chrome Web Inspector to debug
I can use -d option to put files into a database. mongofiles -d test
I can use GD or something to draw user-selected shapes by writing some lines
I can use: Mage::getModel('cms/page')->getCollection()->addStoreFilter($store_id); to retrieve a collection of CMS pages filtered by Store
I can use the below to get the query string. var query_string = request.query;

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.