[R] using a variable and a superscript in a legend
p@tr|ck@g|r@udoux @end|ng |rom un|v-|comte@|r
Sun Oct 20 18:02:30 CEST 2019
Thanks Bert and Peter,
Yes Bert, I was aware of the legend() function syntax, and just quoting
the legend argument within the function.
However, Bert and Peter, I do not understand why it works with your
absolutely reproducible examples and not in the slightly (not so
slightly apparently) different context where I used it...
legend(list(x=0,y=100),legend=c("Sans renard",bquote(.(densren) * "
Probably because the result of bquote() is concatenated in a character
vector, but how to deal with this ?
Le 20/10/2019 à 16:42, Bert Gunter a écrit :
> Assuming you are using base graphics, your syntax for adding the
> legend appears to be wrong.
> legend() is a separate function, not a parameter of plot.default afaics.
> The following works for me:
> > densren <- 1.25
> > plot(1:10)
> > legend (x="center", legend =bquote(.(densren) (ind./km)^2))
> See ?legend
> Bert Gunter
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> On Sun, Oct 20, 2019 at 5:30 AM Patrick Giraudoux
> <patrick.giraudoux using univ-fcomte.fr
> <mailto:patrick.giraudoux using univ-fcomte.fr>> wrote:
> Dear listers,
> I am trying to pass an expression inlcuding a variable and a
> superpscript to a legend. What I want to obtain is e.g. with
> densren = 1.25
> 1.25 ind./km^2
> I have tried many variants of the following:
> legend=bquote(.(densren) (ind./km)^2)
> but if not errors, do obtain
> 1.25 (ind./km^2)
> hence not what I want (no parenthesis, 2 in superscript...)
> Any idea about a correct syntax to get what I need ?
> [[alternative HTML version deleted]]
> R-help using r-project.org <mailto:R-help using r-project.org> mailing list --
> To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help