Set the legend position explicitly with x and y values and add xpd = TRUE
to the legend call to clip the plot to the figure region and not the plot
region (the default). Something like this (you may have to fool around with
y.intersp, etc. to allow enough space between the legend lines):
plot(c(0,1), c(0,1), type="n")
legend(x = .4, y = 1.25, legend=c("", "", "a"), col=c("blue", "red",
"green"), xpd = TRUE, lty = 1, y.intersp= .75, title = 'test')
Cheers,
Bert
Cheers,
Bert
On Sat, Mar 4, 2023 at 7:45 AM Sigbert Klinke <[email protected]>
wrote:
> Hi,
>
> my MWE is not working as expected:
>
> plot(c(0,1), c(0,1), type="n")
>
> legend("top", legend=c("", "", "a"), col=c("blue", "red", "green"),
> title="test", y.intersp=0.2, lwd=1)
>
> The lines are not below the title. I want (nearby) lines as in the plot,
> but below the title. Is there a way to achieve this?
>
> Thanks Sigbert
>
> ______________________________________________
> [email protected] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.