Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 自动绘图-如何调整加载标签?_R_Ggplot2_Ggfortify - Fatal编程技术网

R 自动绘图-如何调整加载标签?

R 自动绘图-如何调整加载标签?,r,ggplot2,ggfortify,R,Ggplot2,Ggfortify,我希望能够调整装载标签的位置,使它们不会落在箭头上方。但是,我不知道需要在哪里进行调整。geom_文本可用于调整站点位置的位置,但我无法找到向量存储在str(g)中的位置 库(ggplot2) 图书馆(GGF) df您可以通过图层数据(g,2)获得坐标。但是autoplot(prcomp.obj)将其他参数传递给ggbiplot(),因此您可以使用ggbiplot()的参数更改标签和加载。标签的位置,例如loadings.label.hjust(请参见?ggbiplot) 示例代码: arrow

我希望能够调整装载标签的位置,使它们不会落在箭头上方。但是,我不知道需要在哪里进行调整。
geom_文本
可用于调整站点位置的位置,但我无法找到向量存储在
str(g)
中的位置

库(ggplot2)
图书馆(GGF)

df您可以通过
图层数据(g,2)
获得坐标。但是
autoplot(prcomp.obj)
将其他参数传递给
ggbiplot()
,因此您可以使用
ggbiplot()
的参数更改
标签和
加载。标签的位置,例如
loadings.label.hjust
(请参见
?ggbiplot

示例代码:
arrow_ends <- layer_data(g, 2)[,c(2,4)]

autoplot(prcomp(df[,-11], scale=TRUE), data=df,
         loadings.label=TRUE, loadings=TRUE, 
         loadings.label.size=8, loadings.colour='blue',
         label.size=5, loadings.label.vjust = 1.2) +     # change loadings.label position
     geom_point(data = arrow_ends, aes(xend, yend), size = 3) +  # the coordinates from layer_data(...)
     geom_text(vjust=-1, label=rownames(df)) +
     theme(plot.background=element_blank(),
           panel.background=element_rect(fill='transparent',color='black',size=1),
           legend.text=element_text(hjust=1),
           legend.key=element_blank()) 
箭头\u结束
arrow_ends <- layer_data(g, 2)[,c(2,4)]

autoplot(prcomp(df[,-11], scale=TRUE), data=df,
         loadings.label=TRUE, loadings=TRUE, 
         loadings.label.size=8, loadings.colour='blue',
         label.size=5, loadings.label.vjust = 1.2) +     # change loadings.label position
     geom_point(data = arrow_ends, aes(xend, yend), size = 3) +  # the coordinates from layer_data(...)
     geom_text(vjust=-1, label=rownames(df)) +
     theme(plot.background=element_blank(),
           panel.background=element_rect(fill='transparent',color='black',size=1),
           legend.text=element_text(hjust=1),
           legend.key=element_blank())