-1

I am trying to generate a ternary plot using ggtern.

My data ranges from 0 - 1000 for x, y,and z variables. I wondered if it is possible to extend the axis length above 100 to represent my data.

zx8754
  • 52,746
  • 12
  • 114
  • 209
M.Carter
  • 1
  • 1
  • 1
    Welcome to Stack Overflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – zx8754 Mar 24 '16 at 13:15

2 Answers2

2

@Nevrome is on the right path, your points will still be plotted as 'compositions', ie, concentrations sum to unity, but you can change the labels of the axes, to indicate a range from 0 to 1000.

library(ggtern)
set.seed(1)
df = data.frame(x = runif(10)*1000,
                y = runif(10)*1000,
                z = runif(10)*1000)
breaks = seq(0,1,by=0.2)
ggtern(data = df, aes(x, y, z)) + 
  geom_point() +  
  limit_tern(breaks=breaks,labels=1000*breaks)
Nicholas Hamilton
  • 10,044
  • 6
  • 57
  • 88
1

I think there is no direct solution to do this with ggtern. But an easy workaround could look like this:

library(ggtern)

df = data.frame(x = runif(50)*1000,
                y = runif(50)*1000,
                z = runif(50)*1000,
                Group = as.factor(round(runif(50,1,2))))

ggtern() + 
  geom_point(data = df, aes(x/10, y/10, z/10, color = Group)) + 
  labs(x="X", y="Y", z="Z", title="Title") +
  scale_T_continuous(breaks = seq(0,1,0.2), labels = 1000*seq(0,1,0.2)) +
  scale_L_continuous(breaks = seq(0,1,0.2), labels = 1000*seq(0,1,0.2)) +
  scale_R_continuous(breaks = seq(0,1,0.2), labels = 1000*seq(0,1,0.2))
nevrome
  • 1,471
  • 1
  • 13
  • 28