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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:14:22+00:00 2026-06-12T03:14:22+00:00

I am not sure how to phrase this question, but I am trying to

  • 0

I am not sure how to phrase this question, but I am trying to add labels with lines to the corresponding point on a basic scatterplot. So far I have the following:

example <- data.frame(name=paste("label_",1:200,sep=""),plot=rep(FALSE,200),rank=c(1:200),score=exp(seq(6,0,length.out=200)))
example$plot[c(1:3,7,8,35,37,150:155,183)] <- TRUE

plot(x=example$score,y=example$rank,ylim=rev(range(c(1:nrow(example)))),axes=FALSE,ylab="",xlab="Score",frame.plot=FALSE)
axis(side=1,labels=TRUE)
axis(side=2,labels=example$name[which(example$plot==TRUE)],at=example$rank[which(example$plot==TRUE)],las=1,tick=FALSE)
points(x=example$score[which(example$plot==TRUE)],y=example$rank[which(example$plot==TRUE)],col="Red",cex=1.5,pch=16)

The code gives the following plot:

What I currently have.

This would work well for my purposes, except the labels overlap really badly. I am looking for a general method to make a graph like the following:

What I would like to have.

The code lies within a function, so it needs to work for any variation on the general dataset. I am looking into the code behind safeplot in the safe package, but so far I cannot replicate what they did to solve a similar problem.

I have now also tried using the linestack() function in the vegan package.

par(mar=c(5,10,4,2))
plot(x=example$score,y=example$rank,ylim=rev(range(c(1:nrow(example)))),axes=FALSE,ylab="",xlab="Score",frame.plot=FALSE)
axis(side=1,labels=TRUE)
points(x=example$score[which(example$plot==TRUE)],y=example$rank[which(example$plot==TRUE)],col="Red",cex=1.5,pch=16)
linestack(x=example$rank[which(example$plot==TRUE)],labels=example$name[which(example$plot==TRUE)],add=TRUE,side="left",air=1.1,at=0,hoff=2)

However, linestack() just gave me the following:

enter image description here

I tried varying all the parameters and could not get the labels to separate.

  • 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-12T03:14:24+00:00Added an answer on June 12, 2026 at 3:14 am

    There are several issues here, notably that normally you can’t draw outside the plotting region as clipping obscures anything outside the limits (i.e. in the margins). You also need to leave a lot of space in that margin to accommodate the labels and the lines.

    Whilst this is a bigger job than something I can get into now on SO, I can suggest that you look at the linestack() function in the vegan package and how it is used in the vegan:::plot.prc() method.

    I recently used the `linestack() function to do something very similar to what you describe to improve some plots from the glmnet package. If you need more help comment back and I’ll see about hacking an example together.

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

Sidebar

Related Questions

I am not exactly sure how to phrase this question but the error I
Not sure how to phrase this question, but here is the problem. I have
First, this question may have been asked before, but I'm not sure what phrase
Not sure how to phrase this question exactly, but I'll give it a shot.
I'm not quite sure how to phrase this question, but I couldn't find any
I am not sure how to phrase this question correctly, but this is what
I'm not even sure how I should phrase this question. I'm passing some CustomStruct
I am not sure how to phrase my question properly but I want to
Not really sure how to phrase this question so it's generic enough. (and will
I think the title for this question is probably wrong, but I'm not sure

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.