3

I am using this factoextra package in R to do Correspondent Analysis.

When I print out the result plot, I can't find the option to hide the x and y zeroline.
I know that the theme setting is based on ggplot2. Can anyone help me to figure out how to hide those two lines?
Please find the code below.

fviz_ca_biplot(gen_show_ns.ca,
               geom =c( "text", "point"),
               col.col = "#FF6600",
               col.row = "#336699",
               MAP = "symbiplot",
               labelsize = 5,
               repel = TRUE,
               title = " "
) +
  theme(axis.line=element_blank(),
        axis.text.x=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks=element_blank(),
        axis.title.x=element_blank(),
        axis.title.y=element_blank(),
        legend.position="none",
        panel.background=element_blank(),
        panel.border=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        plot.background=element_blank())})

Other reference link please see here: ggplot2 theme

Any suggestion helps! Thanks so much

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
backpackerice
  • 87
  • 1
  • 9

1 Answers1

4

The only way I have found so far is to add the option

axes.linetype=NA

You'll get the plot without the lines. However this makes a warning message show up saying that there can be missing values, but the plot seems ok.

The lines you are trying to get rid off are geom_hline and geom_vline added by the function:

.fviz_finish(p, X, axes, axes.linetype, ...)

called at some point by the one you are using.

I have use the following code and data to produce the example:

library(ggplot2)
library(factoextra)
library(FactoMineR)

res.ca<-CA(housetasks,graph = FALSE)
fviz_ca_biplot(res.ca,axes.linetype=NA)

enter image description here

fviz_ca_biplot(res.ca,axes.linetype=NA)

## Warning: Removed 1 rows containing missing values (geom_segment).
## Warning: Removed 1 rows containing missing values (geom_segment).
## Warning: Removed 1 rows containing missing values (geom_segment).
## Warning: Removed 1 rows containing missing values (geom_segment).

enter image description here

Following the options of your example:

fviz_ca_biplot(res.ca,
               geom =c( "text", "point"),
               col.col = "#FF6600",
               col.row = "#336699",
               MAP = "symbiplot",
               labelsize = 5,
               repel = TRUE,
               title = " ",
               axes.linetype=NA
) +
  theme(axis.line=element_blank(),
        axis.text.x=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks=element_blank(),
        axis.title.x=element_blank(),
        axis.title.y=element_blank(),
        legend.position="none",
        panel.background=element_blank(),
        panel.border=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        plot.background=element_blank())

## Warning: Removed 1 rows containing missing values (geom_segment).
## Warning: Removed 1 rows containing missing values (geom_segment).
## Warning: Removed 1 rows containing missing values (geom_segment).
## Warning: Removed 1 rows containing missing values (geom_segment).

enter image description here

Hope it helps you!

storm surge
  • 841
  • 8
  • 9