I am trying to draw the two horizontal and vertical lines at 0.00 point using ggplot2, I have tried this
theme <-
theme(
panel.grid = element_blank(),
axis.line.x = element_line(),
axis.line.y = element_line(),
panel.grid.major.x = element_line(),
panel.grid.major.y = element_line()
)
ggplot(data=eigenvec) geompoint() theme
I want only the two lines at 0.0, not the whole grid, how can I have that?
eigenvector data
PC1 | PC2 |
---|---|
0.651002 | -0.613762 |
-0.52076 | -0.21174 |
-0.482915 | -0.202607 |
0.108556 | 0.439427 |
0.244979 | 0.586785 |
CodePudding user response:
You manually added a grid with panel.grid.major
which you should remove, and then you have to draw the lines at the coordinates you want with geom_hline
and geom_vline
:
theme <-
theme(
panel.grid = element_blank(),
axis.line.x = element_line(),
axis.line.y = element_line())
ggplot(data=eigenvec,aes(x=PC1,y=PC2)) geom_point() theme
geom_hline(yintercept=0) geom_vline(xintercept=0)
(Pay attention that the code you shared was plenty of errors on ggplot formatting)