Legend

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Legend

stat stat
I have following syntax for putting a legend :

legend("bottom", fill=c("red","blue"), legend=expression(p==0.30, p==0.50), bty="n")

However what I want is that : the value "0.30" should be a value of a variable instead of a constant, so that I can put the name of this variable and in legend it's value will be displayed. Can anyone tell me how to do that?

Regards,


thanks in advance
       
---------------------------------
 Why delete messages? Unlimited storage is just a click away.
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Legend

Frede Aakmann Tøgersen
You can use bquote (see ?bquote or the example in ?plotmath using bquote).

Here you go,

pvalue <- 0.3
legend("bottom", fill=c("red","blue"), legend=c(bquote(p==.(pvalue)), expression(p==0.50)), bty="n")


Med venlig hilsen
Frede Aakmann Tøgersen
 

 

> -----Oprindelig meddelelse-----
> Fra: [hidden email]
> [mailto:[hidden email]] På vegne af stat stat
> Sendt: 26. september 2007 00:13
> Til: [hidden email]
> Emne: [R] Legend
>
> I have following syntax for putting a legend :
>
> legend("bottom", fill=c("red","blue"),
> legend=expression(p==0.30, p==0.50), bty="n")
>
> However what I want is that : the value "0.30" should be a
> value of a variable instead of a constant, so that I can put
> the name of this variable and in legend it's value will be
> displayed. Can anyone tell me how to do that?
>
> Regards,
>
>
> thanks in advance
>        
> ---------------------------------
>  Why delete messages? Unlimited storage is just a click away.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Legend

P Ehlers
In reply to this post by stat stat
How about

a <- .33
b <- .55
legend("bottom", fill=c("red","blue"),
   legend=c(bquote(p == .(a)), bquote(p == .(b))), bty="n")

or look at ?substitute

  - Peter Ehlers

stat stat wrote:

> I have following syntax for putting a legend :
>
> legend("bottom", fill=c("red","blue"), legend=expression(p==0.30, p==0.50), bty="n")
>
> However what I want is that : the value "0.30" should be a value of a variable instead of a constant, so that I can put the name of this variable and in legend it's value will be displayed. Can anyone tell me how to do that?
>
> Regards,
>
>
> thanks in advance
>        
> ---------------------------------
>  Why delete messages? Unlimited storage is just a click away.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Legend

slre
In reply to this post by stat stat
>>> P Ehlers <[hidden email]> 26/09/2007 11:06:54 >>>
>a <- .33
>b <- .55
>legend("bottom", fill=c("red","blue"),
>  legend=c(bquote(p == .(a)), bquote(p == .(b))), bty="n")

paste should do it:

legend("bottom", fill=c("red","blue"),
  legend=paste("p=", c(a,b), sep=""), bty="n")

and would be even easier if a and b were already in a vector.

> I have following syntax for putting a legend :
>
> legend("bottom", fill=c("red","blue"), legend=expression(p==0.30, p==0.50), bty="n")
>
> However what I want is that : the value "0.30" should be a value of a variable instead of a constant, so that I can put the name of this variable and in legend it's value will be displayed. Can anyone tell me how to do that?
>
> Regards,
>
>
> thanks in advance
>        
> ---------------------------------
>  Why delete messages? Unlimited storage is just a click away.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
>

______________________________________________
[hidden email] 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.

*******************************************************************
This email contains information which may be confidential and/or privileged, and is intended only for the individual(s) or organisation(s) named above. If you are not the intended recipient, then please note that any disclosure, copying, distribution or use of the contents of this email is prohibited. Internet communications are not 100% secure and therefore we ask that you acknowledge this. If you have received this email in error, please notify the sender or contact +44(0)20 8943 7000 or [hidden email] immediately, and delete this email and any attachments and copies from your system. Thank you.

LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex TW11 0LY, UK
______________________________________________
[hidden email] 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.