Skip to content

altering legend with plot(density(..))

5 messages · Brian Hook, Uwe Ligges, Martin Maechler

#
I'm having a hard time modifying the legend that is emitted by default 
when calling plot(density(...)) and then legend().  I've looked at the 
docs and I'm not sure what I'm doing wrong, if anything.  Any advice 
appreciated.

Thanks,

Brian
#
Brian Hook wrote:

            
So, can you tell us what is wrong with
   set.seed(123)
   plot(density(rnorm(100)))
and where the legend is? Maybe you don't like the defaults for "xlab" or 
"main"?

Uwe Ligges
#
On Tue, 01 Mar 2005 16:38:42 +0100, Uwe Ligges wrote:

            
Ah, yes, I was confusing xlab with the legend.  Sorry for that.  In 
addition, "legend" wasn't showing up where I expected (beneath xlab) 
-- is there a way to put a legend outside of the graph itself?

Thank you,

Brian
#
Brian Hook wrote:

            
So you are using legend() specifying coordinates outside the plot region?

Yes, it work if you set par(xpd=TRUE) before, see ?par.

Uwe Ligges
#
Brian> I'm having a hard time modifying the legend that is
    Brian> emitted by default when calling plot(density(...))
    Brian> and then legend().  I've looked at the docs and I'm
    Brian> not sure what I'm doing wrong, if anything.  Any
    Brian> advice appreciated.

    Brian> ______________________________________________
    Brian> R-help at stat.math.ethz.ch mailing list
    Brian> https://stat.ethz.ch/mailman/listinfo/r-help
    Brian> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

could  PLEASE do what the line above asks you to do,
and then re-post your question accordingly?

Thank you,
Martin Maechler, ETH Zurich