Problems to use scale from - 1 to 1
asierrl opened this issue · comments
Hi, Martin.
Great package to make nice ternary plots!! Thanks for building it!
I am trying to make a ternary plot of an index for the three main dimensions of tree performance. The index varies from -1 to 1 and hence I use "axis.labels = seq(-1, 1, by = 0.2)".
I find three different problems, which I think come, at least two of them, from the fact that the code assumes always positive scales:
-
I cannot set the arrow to depart from the very center of the plot. If I use c(0,0,0) as the origin of arrows, I get the following error message and the arrows are missing: Error in if (x_deviation == 1) { : missing value where TRUE/FALSE needed. It works smoothly with c(0.001, 0.001, 0.001)
-
I cannot make TernaryArrow correctly read the destination ternary coordinates from a data frame (where each coordinate is in a separate field). When using the data frame (instead of a list of vectors), I get the following error message and no arrow is displayed: Error in CoordinatesToXY(toCoordinates) : Coordinates must be ternary points
Best regards,
Asier
Hi, glad the package is coming in handy.
I'm afraid that I'm not quite sure that I've understood what you are trying to plot. Could you provide a couple of example data entries?
If the three indices are independent, then a 3D plot would be more appropriate than a ternary plot, which assumes that the three components being plotted sum to 100%. For example, where ought a tree with the indices 1, 1, 1 plot in ternary space?
I suspect that I've got the wrong end of the stick somewhere -- do put me right if so!
Cheers,
Martin
Sure, Martin. I am trying to plot something weird. These are my points:
A tibble: 5 x 5
expto trat Defensas Growth Reproduc
1 NUT Fertil -0.139 0.486 0.108
2 IND Clip 0.00327 -0.337 -0.0874
3 IND MJ 0.121 0.151 -0.0507
4 IND MWl -0.0557 0.434 0.0347
5 IND MWh -0.0939 0.222 0.107
As you say, there may be areas that fall outside of the space of the ternary plot, but that is not the case in my case. In fact, the three variables are not completely dependent, but are not either independent, due to the existence of trade-offs between all three functions. That was my idea, to show in a clear way how different treatments change the balance between the three functions.
I was in fact, inspired by the example included in the Ternary vignette displaying a ternary plot with a colourful background and different colours plot on top of it. Actually DN of colours do not add to a constant, and in fact, R-G-B channels are completely independent.
It is true that both (mine and the colour one) examples are weird and I don't really understand how the values for the ternary plot are calculated. In fact, checking it again, I don't understand the position of the different colours in that plot (as related to their RGB DN values).
Finally, I identified the negative values as the problem, because adding unity to the index values seem to work, although there seem to be some changes to the values.
Do you think I could still use it?
Asier
Hi, Martin.
I've been thinking deeper on the issue and looked for alternatives. I really think a 3D plot would not fit my needs, as visualizing the tensions of the three-sided trade-off in such a plot is really difficult. I've been playing around with a spider or radar plot, but seeing the direction of the effect size of the treatments (this was the index) on the three functions requires to visualize a central point.
Maybe I misunderstand the relationship between a 3D plot, a spider plot and a ternary plot, but isn't a ternary plot an isometric view of a 3D plot where the center is the origin of the 3D plot? If this is true, doesn't using it make sense even if the three dimensions don't sum up to a constant? I realize that in this situation (this isometric view) we lose some information, that on the magnitude of the overall sum, where the central point is equal for any case with X=Y=Z. This leaves only the relative magnitude of the three dimensions. That is exactly what I am looking for, as the overall value of the three effect sizes is not of interest for me, I am only interested in it's bias in one or other dimension.
Does that makes sense to you? Is there a way I can work with this "-1 to 1" scale? Or work with a 0 to 2 scale and simply change the tick labels of the plot?
Thanks a lot.
Asier
I think the point is that the coordinates of your first data point, -0.139 0.486 0.108
, do not exist in Ternary space. The coloured background is obscuring the gridlines, which perhaps makes this less obvious, but the lines -0.129 and 0.486 do not intersect at 0.108. You would need to think of a way of projecting your data into a suitable coordinate system, where the three variables only have two degrees of freedom.
Oh! You're right...I did not fit my conceptual reasoning with it's corresponding maths. I have three coordinates in the original xyz (in a scatter plot; as a,b and c in 1 below), and I would need to transform them in coordinates in the new triangle axes (as a', b' and c' in 4).
I would then need to move the origin to -1 and rotate the coordinates.
Thanks a lot! I missed that step.
Yep, that looks like a good approach – glad you could figure it out.