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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:33:16+00:00 2026-06-04T04:33:16+00:00

Yesterday, I asked a question regarding how to plot multiple (horizontal-ish) lines, each with

  • 0

Yesterday, I asked a question regarding how to plot multiple (horizontal-ish) lines, each with a user-specified color, without using a loop.

I tried to use the suggested function matplot() to plot the short vertical lines shown in the plot below with the relevant code.

    ci = matrix(1:30, nrow=3, byrow=T)
    ci=list(rbind(ci[1,], ci[1,]+2),
            rbind(ci[2,], ci[2,]+2),
            rbind(ci[3,], ci[3,]+2))
    x = rbind(1:10, 1:10)
    plot(-5, xlim=c(1,10), ylim=c(1,32)) 
    invisible(mapply(matlines, x=list(x), y=ci, 
              col=c("red","blue","black"), 
              lty = 1))

Plot 1: Desired plot

This is all good. However, I am trying to wrap this code inside a function, and I would like to be able to input a list of optional arguments, which can then be passed to mapply/matlines. I tried to use the argument MoreArgs in mapply() to no avail. It seems that arguments that MoreArgs takes are not treated the same as others. As you can see in the first code, each item of the list gets a different color, but when I put col inside the list args.ci, the 3 colors are recycled within each item of the list. I wonder if there is anyway to resolve this issue so that if I have multiple values for an argument, each value gets applied to one item of a list. Thanks!

    args.ci = list(col=c("red","blue","black"), lty=1:3)
    plot(-5, xlim=c(1,10), ylim=c(1,32)) 
    invisible(mapply(matlines, x=list(x), y=ci, 
              MoreArgs = args.ci))

Plot 2: Not what I want

  • 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-04T04:33:17+00:00Added an answer on June 4, 2026 at 4:33 am

    Here’s a general approach to this sort of problem. You should be able to adapt it to do more exactly what you want:

    myFun <- function(...) {
        fixedArgs <- list(matlines, x=list(x), y=ci)
        dots <- list(...)
        allArgs <- c(fixedArgs, dots)
        plot(-5, xlim=c(1,10), ylim=c(1,32)) 
        invisible(do.call(mapply, allArgs))
    }
    
    myFun(col=c("red","blue","black"), lty=1)
    

    enter image description here

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

Sidebar

Related Questions

Yesterday, I asked this question regarding best practices for a simple information retrieval system
I asked this question yesterday about storing a plot within an object. I tried
Yesterday my friend asked me a question about this query: select * from user
I asked a question yesterday on how to pull out multiple results into one
I asked a question yesterday ( Using Spring in standalone apps ) on how
Using PHP 5.x and MySQL 5.x So I asked a question yesterday about the
I asked this question yesterday, wondering how to produce XML with attributes using MVCContrib.
Yesterday I asked a question about parallel matrix multiplication in Java 7 using the
Yesterday I asked the following question Html.Dropdown - get the the value of each
This question follows on from a question I asked yesterday about why using the

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.