admin管理员组

文章数量:1193356

I need to plot cartesian coordinates on a triangle to match a previous analysis. I have a data frame with the x,y values and I can generate a blank triangle using the Ternary library in R as follows:

par(mfrow = c(1, 2), mar = c(0.3, 0.3, 1.3, 0.3))
TernaryPlot(grid.lines = 0, ticks.col = "white")

As a sample of my df, say

x = c(-0.3463, 0.0002, -0.4330, -0.4329, -0.4330, -0.5773, -0.2885)
y = c(-0.20, 0, 0.25, -0.50, 0.25, -0.50, -0.50)
df = data.frame(x,y)

The only documentation I can find says it is possible to supply cartesian coordinates

arrows(x0 = 0.5, y0 = 0.4, x1 = sqrt(3) / 2, y1 = 0.4, length = 0.1,
       col = cbPalette8[2])
text(x = mean(c(0.5, sqrt(3) / 2)), y = 0.4, "Increasing X", pos = 3,
     col = cbPalette8[2])
text(x = 0.5, y = 0, "(0.5, 0)", col = cbPalette8[3])
text(x = 0.8, y = -0.5, "(0.8, -0.5)", col = cbPalette8[3])

but unfortunately it's not clear to me from the sample how to point to the plot to the df.

TernaryPoints(df[, c("x", "y")])

raises "Error in CoordinatesToXY(coordinates) : Coordinates must be ternary points"

I know this is doable, because I've seen the end product; just not sure how to get there. Advice is appreciated.

本文标签: plot cartesian coordinates with Ternary package in RStack Overflow