r - 如何获得与 ggtern 中显示的值匹配的 geom_crosshair_tern 线?
问题描述
我没有成功获得与geom_crosshair_tern
我的绘图外显示的数据值匹配的线(X,Y,Z)。它们没有直角(我想更改线条位置,而不是数据值位置)。
我怎样才能解决这个问题?
谢谢你的帮助。
这是我的脚本:
points1 <- data.frame(
rbind(c( 1,25,45,30),
c( 2,33,33,34),
c( 3,15,75,10)
)
)
colnames(points1) = c("IDPoint","X","Y","Z")
labFnc <- function(x,digits=2) format(round(unique(x),digits),digits=digits)
#geom_crosshair_tern version
base2 = ggtern(data=points1,aes(X,Y,Z)) +
theme_bw() +
geom_crosshair_tern(lty=2)+
tern_limits(labels=c(20,40,60,80,100), breaks=seq(0.2,1,by=0.2)) +
theme_clockwise() +
theme_showarrows() +
theme_nomask() +
labs(title = "Test",Tarrow = "% Y",Larrow = "% X",Rarrow = "% Z") +
theme(tern.axis.arrow=element_line(size=1,color="black")) +
geom_point(shape=21,size=5,col="black",bg="slategray1") +
geom_text(aes(label=IDPoint), color="black") +
annotate(geom = 'text',
x = points1$X,
y = c(0),
z = 100-points1$X,
vjust = c(-0., -0., -0.),
hjust = c(-0.25, -0.25, -0.25),
angle = c(-60,-60,-60),
label = paste("X=",points1$X)) +
annotate(geom = 'text',
x = 100-points1$Y,
y = points1$Y,
z = c(0),
vjust = c(+0.25, 0.25, 0.25),
hjust = c(1, +1, 1),
label = paste("Y=",points1$Y)) +
annotate(geom = 'text',
x = c(0),
y = 100-points1$Z,
z = points1$Z,
vjust = c(+0.3, 0.3, 0.3),
hjust = c(-0.25, -0.25, -0.25),
angle = c(60,60,60),
label = paste("Z=",points1$Z))
print(base2)
解决方案
推荐阅读
- android - GraphQL 查询是否必须事先写入 .graphql 文件?或者我可以在代码中制作它们吗?
- facebook-graph-api - 如何代表用户点赞 - Facebook Workplace API
- ios - 如何更改 UIAlertAction 的标题
- android - 无法通过图表点击事件区分两个片段
- javascript - OAuth2 HTTPRequest CORS 策略
- xcode - 为什么提交更新显示在主文件夹而不是主分支中?Xcode
- python-3.x - 用另一个二维数组中的列替换 2D numpy 数组中的列
- opengl - Xamarin.Forms OpenGLView 在 XAML 页面中使用时不起作用
- python - 如何在 pyqtgraph 中为单个 PlotItem 设置背景颜色?
- python - 将值分配给 2D numpy 数组作为索引函数的有效方法是什么