本文介绍了R-ggtern + geom_interpolate_tern,为什么图形在对称线(三角形高度)上不平滑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ggtern输出

我正在尝试绘制以下数据

I am trying to plot the following data

    > 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)

缺少平滑插值是我似乎无法摆脱的对函数参数的扭曲.实际上,对于这个单纯形,我有多个响应数组,它们都在输出中表现出非平滑性.

The lack of a smooth interpolation is something I can't seem to get rid of twicking the function parameters. I actually have multiple response arrays for this simplex and they all present the non-smoothness in the output.

我是否缺少使用ggerggeom_interpolate_tern进行插值的一些信息?

Am I missing something about interpolation using ggerg and geom_interpolate_tern?

推荐答案

这是由于R在Windows上并不是天真的抗锯齿.

This is due to the fact that R doesn't nativly anti-alias on 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"))

您可以通过使用其他图形设备进行渲染来解决此问题.

You can fix this by using a different graphics device to render.

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,为什么图形在对称线(三角形高度)上不平滑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 09:02