I generate the following legend:
legend(
"bottomleft"
, legend=c(
expression(bold("Long:" ~ (w==10^2 ~ ";" ~ h==10^5)))
, expression(q[c] == 0.00 ~ ";" ~ beta == 0)
, expression(q[c] == 0.05 ~ ";" ~ beta == 2)
, expression(q[c] == 0.10 ~ ";" ~ beta == 10)
, expression(q[c] == 0.20 ~ ";" ~ beta == 10)
, expression(q[c] == 0.40 ~ ";" ~ beta == 10)
, expression(bold("Wide:" ~ (w==10^3 ~ ";" ~ h==10^3)))
, expression(q[c] == 0.00 ~ ";" ~ beta == 0)
, expression(q[c] == 0.05 ~ ";" ~ beta == 2)
, expression(q[c] == 0.10 ~ ";" ~ beta == 10)
, expression(q[c] == 0.20 ~ ";" ~ beta == 10)
, expression(q[c] == 0.40 ~ ";" ~ beta == 10)
)
, col=c("n", 1, 2, 3, 4, 5, -1, 1, 2, 3, 4, 5)
, lty=c(F, 1, 1, 1, 1, 1, -1, 2, 2, 2, 2, 2)
, cex=.65
)
which gives me:
It would be nicer to have a heading, that also spans the "line+point" sample region:
How can I realize this? (I tried for example to set n
or FALSE
in the lty-section, but that did not work,...).
I also failed with aligning the qc
and beta
-values, but thats a different story,...
Using
@DWin
's proposed solution method:Set up an example plot:
Save the legend and
phantom
hide the titles to be written manuallyThen grab the y-axis values of the two bits of
text
to be replotted from the saved legend with newly specified x-axis values.Result:
A similar approach, but using the
legend
title, and creating two legends (without boxes) before adding the rectangle (box) afterwards