R晶格:如何调整图例标记线宽?

Bry*_*yan 2 r line legend width lattice

有没有人知道如何调整格子图中的标记线宽度,理想情况下使用auto.key?我需要独立于绘图中的线条粗细调整它,我需要非常薄.默认情况下,图例中的线条也非常薄,这使得很难通过颜色或线条样式区分不同的系列.中等厚度的矩形将是图例中理想的系列标记.

x = seq(1,360*10,1)
y = sin(x*pi/180)
df = data.frame(x=x, y=y, id="x")
p.xy <- xyplot(y~x, groups=id, data=df, type="l", lwd=.1
              ,auto.key=list(lines=T, points=F))
print(p.xy)
Run Code Online (Sandbox Code Playgroud)

谢谢!
布赖恩

Aar*_*ica 5

使用lwd在调用xyplot图例改变线的宽度中的情节,但不是; 图例使用参数设置,可以使用par.settings参数更改参数设置.这通常是更改绘图中线宽的首选方法,因为它也会在图例中更改auto.key,但在您的情况下,此行为可用于根据图例的需要更改它,然后覆盖它与lwd情节中的线条有关.

我更喜欢抓住默认主题并根据需要进行更改然后将整个内容传回去par.settings,但实际上只需要提供par.settings您想要更改的部分.

mtheme <- standard.theme("pdf", color=TRUE)
mtheme$plot.line$lwd <- 5
mtheme$superpose.line$lwd <- 5
p.xy <- xyplot(y~x, groups=id, data=df, type="l", lwd=0.1
              ,auto.key=list(lines=T, points=F), par.settings=mtheme)
print(p.xy)
Run Code Online (Sandbox Code Playgroud)