gpt4 book ai didi

R格子: How to adjust the legend marker line width?

转载 作者:行者123 更新时间:2023-12-04 02:09:47 24 4
gpt4 key购买 nike

有谁知道如何在格子图中调整标记线宽,最好使用 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)

谢谢!
布莱恩

最佳答案

在对 xyplot 的调用中使用 lwd 会更改图中线条的宽度,但不会更改图例中的线条宽度;图例使用参数设置,可以使用 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)

关于R格子: How to adjust the legend marker line width?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19498677/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com