In package 'factoextra',when i use function 'fviz_eig',how to adjust the column width and label size ? ("width=0.6,text.size=17" seems can't work, also no error message show)
library(factoextra)
data(iris)
res.pca <- prcomp(iris[,-5],scale=TRUE)
fviz_eig(res.pca,addlabels = TRUE,choice = 'eigenvalue',
ylim=c(0,3),width=0.6,text.size=17)
i want to change the text size which marked by bursh as below:
CodePudding user response:
Same with ggplot
use theme(text = element_text(size = 10))
to resize label. Use bar_width
inside fvie_eig
to change width of bars.
fviz_eig(res.pca,addlabels = TRUE,choice = 'eigenvalue',
ylim=c(0,3),bar_width=0.2) theme(text = element_text(size = 10))
Manually
fviz_eig(res.pca,choice = 'eigenvalue',
ylim=c(0,3),bar_width=0.2) geom_text(label = round(res.pca$sdev^2,1), vjust=-0.4, hjust = 0, size = 5)
CodePudding user response:
The documentation is not clear about the extra arguments. It just says ...
and to look under the options
i.e.
... optional arguments to be passed to the function ggpar.
When we check the ggpar
link
Use font.x = 14, to change only font size;
If we check the function fviz_eig
...
extra_args <- list(...)
bar_width <- extra_args$bar_width
linetype <- extra_args$linetype
Therefore, instead of width
, change it to bar_width
would work. It is not giving any error because the variadic argument is ...
and anything can be passed as input, but they may not be used within the function as per the extr_args
extraction with bar_width
and linetype
implies
By changing the bar_width
, was able to change to reproduce the changes in the width. Also, make use of label_size
fviz_eig(res.pca,addlabels = TRUE,choice = 'eigenvalue',
ylim=c(0,3),bar_width=0.3, label_size = 10)
-output
fviz_eig(res.pca,addlabels = TRUE,choice = 'eigenvalue',
ylim=c(0,3),bar_width=0.6, label_size = 17)