-->

的R - ggtern + geom_interpolate_tern,为什么情节不是在对称线(

2019-09-27 03:31发布

ggtern输出

我想绘制以下数据

    > foo
    Resp         A         B         C
    1  1.629 0.3333333 0.3333333 0.3333333
    2  1.734 0.1666667 0.6666667 0.1666667
    3  1.957 0.0000000 1.0000000 0.0000000
    4  1.778 1.0000000 0.0000000 0.0000000
    5  1.682 0.6666667 0.1666667 0.1666667
    6  1.407 0.1666667 0.1666667 0.6666667
    7  1.589 0.0000000 0.5000000 0.5000000
    8  1.251 0.0000000 0.0000000 1.0000000
    9  1.774 0.5000000 0.5000000 0.0000000
    10 1.940 0.5000000 0.0000000 0.5000000
    > 

运用

    ggtern() +
     geom_interpolate_tern(
     data = foo,
     mapping = aes(y = A,x = B,z = C,value=Resp),method='auto',base = "identity",n=200)

缺乏一个平滑插补的是我似乎无法摆脱twicking参数的功能。 其实,我有这个单纯多响应阵列,它们都呈现非平滑输出。

我失去了一些关于使用插值ggerggeom_interpolate_tern

Answer 1:

这是由于这样的事实,R不nativly抗混叠在Windows上。

foo <- structure(list(Resp = c(1.629, 1.734, 1.957, 1.778, 1.682, 1.407, 
1.589, 1.251, 1.774, 1.94), A = c(0.3333333, 0.1666667, 0, 1, 
0.6666667, 0.1666667, 0, 0, 0.5, 0.5), B = c(0.3333333, 0.6666667, 
1, 0, 0.1666667, 0.1666667, 0.5, 0, 0.5, 0), C = c(0.3333333, 
0.1666667, 0, 0, 0.1666667, 0.6666667, 0.5, 1, 0, 0.5)), .Names = c("Resp", 
"A", "B", "C"), class = "data.frame", row.names = c("1", "2", 
"3", "4", "5", "6", "7", "8", "9", "10"))

您可以通过使用不同的图形设备渲染解决这个问题。

require(Cairo)
require(ggplot2)
require(ggtern)

g1 <- ggtern() +
    geom_interpolate_tern(
    data = foo,
    mapping = aes(y = A,x = B,z = C,value=Resp),method='auto',base = "identity",n=200)


ggsave("Tern.png", width=12, height=8, dpi = 300, type = "cairo-png")

或者,正如SVG

#  note that you don't need Cairo to render the .svg
ggsave("Tern.svg", width=12, height=8, dpi = 300)



文章来源: R - ggtern + geom_interpolate_tern, why is the plot not smooth at the symmetry line (triangle height)?