【问题标题】:Transparent symbols, solid lines, lattice::xyplot()透明符号、实线、lattice::xyplot()
【发布时间】:2020-09-25 06:06:24
【问题描述】:

我想在 R 中使用 lattice::xyplot() 在由第三个因素变量确定的面板中绘制两个定量变量。我想要透明黑色符号,带有实心红色趋势线。为了提供一个工作示例,我将使用 R 中的 iris 数据集。以下四种尝试都没有达到预期的结果(其中一个是由Add alpha value to lattice xyplot panel function 的线程通知的):

library(datasets)
data(iris)

xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris,
   type = c("p","smooth"), alpha=.1, pch=19, col="black", col.line="red", lwd=2)

xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris,
   type = c("p","smooth"), 
   par.settings = list(superpose.symbol = list(cex=1, pch=20, col="black", alpha = 0.1),
                       superpose.line = list(col = "red", lwd = 2)))

xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris, 
   grid = TRUE, scales=list(tck=c(1,0), x=list(cex=1.1), y=list(cex=1.1)),
   par.settings = list(superpose.symbol = list(pch =20, cex = 1, col = c("#0808084d"))),
   type = c("p", "smooth"), col.line =c("red"),lwd = 2)

xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris,
   par.strip.text=list(cex=0.6),
   type = c("p","smooth"), 
   par.settings = list(superpose.symbol = list(cex=1, pch=20, col="black", alpha = 0.1),
                       superpose.line = list(col = "red", lwd = 2)))

非常感谢任何指导。

【问题讨论】:

    标签: r alpha lattice


    【解决方案1】:

    怎么样

    trans_black <- adjustcolor("black",alpha.f=0.2)
    xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris,
           type = c("p","smooth"), pch=19, col=trans_black,
           col.line="red", lwd=2)
    

    ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-29
      • 2016-08-02
      • 1970-01-01
      • 2012-10-05
      • 2015-10-24
      • 1970-01-01
      • 2023-03-03
      • 2013-07-30
      相关资源
      最近更新 更多