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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:57:27+00:00 2026-06-17T14:57:27+00:00

Can I make such a plot with ggplot2? # data require(vegan) data(dune) data(dune.env) #

  • 0

Can I make such a plot with ggplot2?

# data
require(vegan)
data(dune)
data(dune.env)

# RDA
RDA <- rda(dune ~ A1, data = dune.env)

# extract species scores
df <- data.frame(spec_scores = scores(RDA)$species[ , 1], 
                 taxa = rownames(scores(RDA)$species))
df <- df[abs(df$spec_scores) > 0.05, ]

# plot
par(mar = c(5,4,4,8))
# boxplot of sites-scores along A1-axis
boxplot(scores(RDA)$sites[ , 1] ~ dune.env$Management)
abline(h = 0, lty = "dotted")

# add species scores to plot
rug(df$spec_scores, side=4)
linestack(df$spec_scores, labels=df$taxa, at = par("usr")[2], add = TRUE, hoff = 1)

enter image description here

Basicly I am looking for a way how to plot a labelled rug beneath the boxplot.

Any hints or suggestions?

  • 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-17T14:57:28+00:00Added an answer on June 17, 2026 at 2:57 pm

    This is solution only using ggplot2, so it won’t be most elegant one.

    I started with first steps as suggested by @Eric Fail.

    require(vegan)
    data(dune)
    data(dune.env)
    
    # RDA
    RDA <- rda(dune ~ A1, data = dune.env)
    
    # extract species scores
    df1 <- data.frame(RDA.scores = scores(RDA)$sites[ , 1], Management = dune.env$Management)
    df2 <- data.frame(y = scores(RDA)$species[ , 1], taxa = rownames(scores(RDA)$species))
    # Order data according to species scores
    df2<-df2[order(df2$y),]
    
    # define values for rugs (segments). 4.9 and 5.0 used because data has 4 levels (+1)
    df2$x=4.9
    df2$xend=5
    
    # define coordinates for names (30 is number of species)
    df2$yend2<-seq(min(df1$RDA.scores),max(df1$RDA.scores),length.out=30)
    df2$xend2=5.3
    
    # plot
    P <- ggplot(data = df1, aes( x = Management, y = RDA.scores) ) + 
         geom_segment(y=0,yend=0,x=0,xend=5, lty=2, size = I(0.3)) + 
         geom_boxplot() + 
         #add extra levels to get space
         scale_x_discrete(limits=c("BF", "HF", "NM", "SF", "","")) + 
         #set y scale
         scale_y_continuous(limits=c(-3,5),expand=c(0,0)) +
         #add rugs as segments and add segments connecting rugs and texts
         geom_segment(data= df2, mapping=aes(x=x,xend=xend,y=y,yend=y), size = I(0.3)) +
         geom_segment(data= df2, mapping=aes(x=xend,xend=xend2,y=y,yend=yend2), size = I(0.4)) +
         #add texts
         geom_text(data=df2,mapping=aes(x=xend2+0.1,y=yend2,label=taxa),hjust=0, size=3) +
         #add rectangular to imitate box around plot
         geom_rect(xmax=5,xmin=0.4,ymax=5,ymin=-3,colour="black",fill=NA)
    
    # Final adjustments of plot
    P+theme(axis.line=element_blank(),
            panel.grid=element_blank(),
            panel.background=element_blank())
    

    ggplot2 boxplot

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

Sidebar

Related Questions

How can I make such layout? Header should not scrolls and should be always
In the following, how can I make it such that the program uses the
In the following case, how can I make it such that the text generated
We're looking at patterns such as MVP that can help make us seperate UI
I can't seem to make Xcode find the Core Plot header. I've done the
How can I make such UI: 1) ListBox with items. 2) Detail information about
Is there a way that one can make a control, such as a textbox,
I am trying to make a contour plot of the following data using matplotlib
I need to write a C++ GUI such that user can make a flowchart
How can I make such a conditional search in Bash like in Google python

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.