Use yyplot to modify the font of ggplot2 drawing, causing the arrow position in the figure to shift
Entering edit mode
9 weeks ago
dyunkoeng • 0

Hi, I am using ggplot2 to draw a scatter plot of PCA analysis. In order to make the results more intuitive, I used geom_label_repel to add labels and arrows. In addition, I want to modify the font in the figure and use yyplot. But after using yyplot to modify the font, the arrow in the figure shifted. As shown in the figure below, I tried some methods but couldn't fix this error. In addition, I found that the arrow position is correct when I click to save the picture in Rstudio, but this error occurs when I run the R script to draw. Hope someone can help me solve this problem, thank you very much!

PCAplot <- ggplot(data_x, aes(PC1, PC2)) +
  geom_point(aes(color = Group), size = input$PCApointsize) +
  coord_equal(ratio = input$PCAratio) +
  xlab(xlab) +
  ylab(ylab) +
  geom_label_repel(data = data_x, aes(x = PC1, y = PC2, label = varnames, fill = Group),
                   size = input$PCAlabelsize, segment.size = input$PCASegsize,
                   arrow = arrow(length = unit(input$PCAunitvalue, "cm")),
                   nudge_x = input$PCAnudgex, nudge_y = input$PCAnudgey,
                   direction = "both", box.padding = unit(input$PCAboxunitvalue, 'lines'),
                   segment.color = input$segcolor, show.legend = FALSE)
PCAplot ![enter image description here][1]<- set_font(PCAplot, family = "Times", fontface = "italic", size = 3.8)

enter image description here

arrow ggplot PCA yyplot • 416 views

Login before adding your answer.

Traffic: 2306 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6