Grokbase Groups R r-help January 2009
FAQ

[R] Help with Plot/Legend

Jimdare
Jan 14, 2009 at 1:13 am
Dear R-Users

I have 2 questions:

Firstly, If I create a matplot and legend for multiple vectors and then tag
another vector on using matlines (e.g. a 'total' of all vectors), is there
anyway to add the new line to the legend without recreating it? I have
created the plot this way because I would like to define the lty and lwd for
the 'total' vector so that it can be differentiated from the rest.

Secondly, in many of my black and white matplots there are more than 6
vectors. Unfortunately it is hard to tell them apart because the line type
(lty) for plots repeats from 1 again at lty=7. Is there any way I can
download new line types to avoid this?

Thanks in advance for your help.

Jimdare
--
View this message in context: http://www.nabble.com/Help-with-Plot-Legend-tp21448206p21448206.html
Sent from the R help mailing list archive at Nabble.com.
reply

Search Discussions

2 responses

  • Jim holtman at Jan 14, 2009 at 1:26 am
    You can create your own dashed lines:

    lty
    The line type. Line types can either be specified as an integer
    (0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash,
    5=longdash, 6=twodash) or as one of the character strings "blank",
    "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash",
    where "blank" uses 'invisible lines' (i.e., does not draw them).

    _Alternatively, a string of up to 8 characters (from c(1:9, "A":"F"))
    may be given, giving the length of line segments which are
    alternatively drawn and skipped. See section 'Line Type
    Specification'_

    On Tue, Jan 13, 2009 at 8:13 PM, jimdare wrote:

    Dear R-Users

    I have 2 questions:

    Firstly, If I create a matplot and legend for multiple vectors and then tag
    another vector on using matlines (e.g. a 'total' of all vectors), is there
    anyway to add the new line to the legend without recreating it? I have
    created the plot this way because I would like to define the lty and lwd for
    the 'total' vector so that it can be differentiated from the rest.

    Secondly, in many of my black and white matplots there are more than 6
    vectors. Unfortunately it is hard to tell them apart because the line type
    (lty) for plots repeats from 1 again at lty=7. Is there any way I can
    download new line types to avoid this?

    Thanks in advance for your help.

    Jimdare
    --
    View this message in context: http://www.nabble.com/Help-with-Plot-Legend-tp21448206p21448206.html
    Sent from the R help mailing list archive at Nabble.com.

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.


    --
    Jim Holtman
    Cincinnati, OH
    +1 513 646 9390

    What is the problem that you are trying to solve?
  • Jimdare at Jan 14, 2009 at 3:34 am
    Thanks Jim,

    What happens if I want one solid line and four custom lines
    ("92","11","12","62).
    I tried c("10","92","11","12","62) and it said that you can't use 0's. I
    also tried:

    ownlines<-c("92","11","12","62)
    lty=c(1,ownlines)

    which resulted in the same thing.



    jholtman wrote:
    You can create your own dashed lines:

    lty
    The line type. Line types can either be specified as an integer
    (0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash,
    5=longdash, 6=twodash) or as one of the character strings "blank",
    "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash",
    where "blank" uses 'invisible lines' (i.e., does not draw them).

    _Alternatively, a string of up to 8 characters (from c(1:9, "A":"F"))
    may be given, giving the length of line segments which are
    alternatively drawn and skipped. See section 'Line Type
    Specification'_

    On Tue, Jan 13, 2009 at 8:13 PM, jimdare wrote:

    Dear R-Users

    I have 2 questions:

    Firstly, If I create a matplot and legend for multiple vectors and then
    tag
    another vector on using matlines (e.g. a 'total' of all vectors), is
    there
    anyway to add the new line to the legend without recreating it? I have
    created the plot this way because I would like to define the lty and lwd
    for
    the 'total' vector so that it can be differentiated from the rest.

    Secondly, in many of my black and white matplots there are more than 6
    vectors. Unfortunately it is hard to tell them apart because the line
    type
    (lty) for plots repeats from 1 again at lty=7. Is there any way I can
    download new line types to avoid this?

    Thanks in advance for your help.

    Jimdare
    --
    View this message in context:
    http://www.nabble.com/Help-with-Plot-Legend-tp21448206p21448206.html
    Sent from the R help mailing list archive at Nabble.com.

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide
    http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.


    --
    Jim Holtman
    Cincinnati, OH
    +1 513 646 9390

    What is the problem that you are trying to solve?

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide
    http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
    --
    View this message in context: http://www.nabble.com/Help-with-Plot-Legend-tp21448206p21449456.html
    Sent from the R help mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post

2 users in discussion

Jimdare: 2 posts Jim holtman: 1 post