How to use a range of axes and labels from source data in ggtern?

I use ggtern in R to make a triple plot, and would like to have axis labels and gaps in my ggtern plot, just like the original data. In the case of the generated data in the code below, each axis will reach a maximum of 12, 10 and 4.

Following the previous post, I tried to use gaps and labels for this, but each axis is still on the 0-1 scale, there are no labels (because of them more than 1), and axes with labels do not intersect the points on the graph. ( How to change the labels of the triple plot made by ggtern? )

library(ggtern)
labFnc <- function(x,digits=2) format(round(unique(x),digits),digits=digits)

mydata <- data.frame(
  x = runif(50, min = 0.25, max = 12),
  y = runif(50, min = 0.1, max = 10),
  z = runif(50, min = 0.5, max = 4),
  value = runif(50, min = 10000, max = 20000))

ggtern(data = mydata,aes(x = x, y = y, z = z,col=value)) + 
  theme_bw() +
  geom_point(alpha = 0.8, size = 3) +
  theme_showarrows() +
  scale_T_continuous(breaks=unique(mydata$x),labels=labFnc(mydata$x))+ 
  scale_L_continuous(breaks=unique(mydata$y),labels=labFnc(mydata$y))+ 
  scale_R_continuous(breaks=unique(mydata$z),labels=labFnc(mydata$z))

enter image description here

Is there any way to do this? Any help would be greatly appreciated.

: tern_limits. , . , .

ggtern(data = mydata,aes(x = x, y = y, z = z,col=value)) + 
  theme_bw() +
  geom_point(alpha = 0.8, size = 3) +
  theme_showarrows() +
  tern_limits(T=12, L=10, R=4)

enter image description here

+4
1

, , , , limit_term(...) ( ) [0,1], [0,100%]. , , , 100% 0%.

, :

tern_limits(T=12, L=10, R=4)

, 1200%, 1000% 400% , , .

, limits_tern zoom.

library(ggtern)

n  = 100
df = data.frame(id=1:n,
                x=runif(n),
                y=runif(n),
                z=runif(n))
base = ggtern(df,aes(x,y,z,color=id)) + geom_point(size=3)
base

#Top Corner
base + limit_tern(1.0,0.5,0.5)

#Left Corner
base + limit_tern(0.5,1.0,0.5)

#Right Corner
base + limit_tern(0.5,0.5,1.0)

#Center Zoom Convenience Function
base + theme_zoom_center(0.4) # Zoom In
base + theme_zoom_center(0.6) # Zoom In
base + theme_zoom_center(0.8) # Zoom In
base + theme_zoom_center(1.0) ##Default as per no zoom
base + theme_zoom_center(1.2) # Zoom Out
base + theme_zoom_center(1.4) # Zoom Out
base + theme_zoom_center(1.6) # Zoom Out
base + theme_zoom_center(1.8) # Zoom Out
base + theme_zoom_center(2.0) # Zoom Out

#Left Zoom Convenience Function 
#   (try theme_zoom_R and theme_zoom_T for Right and Top respectively)
base + theme_zoom_L(0.4) # Zoom In
base + theme_zoom_L(0.6) # Zoom In
base + theme_zoom_L(0.8) # Zoom In
base + theme_zoom_L(1.0) ##Default as per no zoom
base + theme_zoom_L(1.2) # Zoom Out
base + theme_zoom_L(1.4) # Zoom Out
base + theme_zoom_L(1.6) # Zoom Out
base + theme_zoom_L(1.8) # Zoom Out
base + theme_zoom_L(2.0) # Zoom Out

:, , , ( ) scale_X_continuous (...) [X = T, L, R]. , x y , , .

, , , , T, L R. , .

ggtern() + 
  scale_T_continuous(limits=c(0.5,1.0),
                     breaks=seq(0,1,by=0.1),
                     labels=LETTERS[1:11]) + 
  scale_L_continuous(limits=c(0.0,0.5),
                     breaks=seq(0,1,by=0.1),
                     labels=LETTERS[1:11]) +
  scale_R_continuous(limits=c(0.0,0.5),
                     breaks=seq(0,1,by=0.1),
                     labels=LETTERS[1:11])
+1

Source: https://habr.com/ru/post/1695932/


All Articles