I would like a fairly plain, publication-quality cluster plot. I have created the plot and removed the title, legend and adjusted the axis titles, with the script provided. However, I would also like to remove all of the individual row labels 'attributes' that are my sample ID's within each of the two cluster's e.g. CLR45, HTR132. Is this possible?
fviz_cluster(k2, data = Chem)+ theme(legend.position = "none")+labs(title = "") + theme(
axis.title.x = element_text(margin = unit(c(3, 0, 0, 0), "mm")),
axis.title.y = element_text(margin = unit(c(0, 3, 0, 0), "mm")))
dput(head(Chem,50))
structure(c(0.147411356827536, -0.94833184269442, -0.236098761737746,
-0.156408346996621, -1.07782876612066, 0.15737266025443, -0.85369947703763,
-0.684357344128487, -0.744125156240499, -0.166369650423515, 1.06883177595158,
-1.72531338325188, -1.16249983257523, -0.908486633211519, -1.30693870691714,
-1.04296420835121, 0.336676092365792, -0.45026675161856, -0.455247403332007,
-0.935222767283235, -0.798912316639064, 0.185622913832727, -0.345812539076084,
0.264855107585394, -0.649213869051943, -0.745838498773852, -0.952615203252478,
0.510998876988382, 1.40751604176986, -0.749105803729271, 0.222121124079889,
0.146973059409158, -0.25104071265341, -0.176330949625734, -0.734163852813605,
1.1584834941196, 0.869605741211104, 0.202198517226101, 0.301811538821014,
-0.0567953296263845, -0.669415393212821, -0.191272904766074,
-0.71922190189794, 0.222121124079889, -0.51999586293279, -0.231118110024299,
0.5608053856735, -0.285905270422864, -0.614628232814256, 0.0378370402550813,
1.21148988263212, -0.722729092058211, 0.938866964062205, 1.29275958711264,
1.23956487191698, 1.86977449177269, 1.84761002727152, 2.09068032585176,
0.430561900436177, -0.339283848035902, 3.19668712695198, -0.305298335931744,
-0.0186379222283033, 3.76926913851535, -0.987963856121806, 0.356680351444172,
3.44123505721924, 0.255462628028634, -1.00052371956831, -0.425184448439876,
-0.0334142322231424, -0.313100227585446, -1.0460909046001, 0.779075947446034,
-1.04523092273039, -0.432924280356334, -0.788096532267007, 0.836910424803157,
0.471935569011041, -0.841678386878241, 3.4264587472244, 0.770476135624245,
1.97394747659788, 0.635952609659098, -0.86162640581326, -0.502562073822641,
0.695796664499772, -0.659190958982183, 0.126169915328244, -0.127243800150166,
-0.945851372685624, -0.589742302104659, -0.506994966919312, -0.665840298627189,
-0.90004481199628, -0.82320799963024, -0.566839021759986, -0.759669866554213,
-0.980575700633291, 0.208917251495781, -1.23882313589815, -0.816688277463794,
0.346387764578252, 0.524062438145321, 1.46662027130976, -0.917496601945682,
1.0860688452788, 2.10423292402831, 0.254400170526879, -0.804087236829436,
-0.843150462529107, -0.300045614716482, 0.672754716385498, -0.9527795153661,
-0.622632253058524, 0.0175006072532231, 0.578246912369032, 1.71864108103204,
-1.24512365636358, 2.67546329317061, -1.0435070073998, -1.24421134102627,
1.42382713735224, 2.28432699595981, 0.587773297320356, 0.00106885031820219,
0.211304610661984, -0.589869547527789, 0.65259305148912, 0.00867987889811877,
-1.54754862951275, 0.235750629237659, -0.331548216154132, 1.18561706626058,
-0.368091233667634, -1.09769148192, -1.03846659132395, -0.70957943281297,
-0.316426967333605, -1.05358783984799, -1.19471949412263, -0.788965988305396,
0.663933988919855, 0.346387764578252, 0.137210492538405, 0.146031220893509,
-0.456298517515165, -0.534424969210994, 0.450976402525343, 0.193915175837746,
1.53543257619906, -0.518118831649496, -0.16974850422888, 0.380309904408398,
-0.518118831649496, -0.114742659464473, 3.20394309995186, 1.0953858473389,
0.893697766122234, 0.710344953491444, -0.316430750432833, 0.453651027510375,
-0.444777708547519, 1.99381459314849, -0.664801077853449, 1.99381459314849,
0.343639347733259, 0.105280700089759, -0.811483324057402, 3.43885470777859,
-0.829818602394972, 0.948923628687728, -1.17727227024187, 0.507850124084635,
-0.054162900383238, 0.0383202589981529, -0.111075611598317, 0.215292379866875,
-0.243089627330857, -0.609795233089042, -0.499783553311926, -0.367182807190326,
-0.719806922617856, 0.105280700089759, -0.353101307107973, 0.728680241580711,
-0.848153880732542, -0.994836126936495, -1.26986533125513, -0.976500848598925,
0.398645192497665, -1.01317140527406, 0.123615978427329, -0.774812757630565,
-1.08651252837604, -0.646465799515879, -0.536454109987066, -0.829818602394972,
0.508656872274782, -0.518118831649496, 0.675002376238412, -0.0617082448613822,
-0.668996727923662, -1.60481832778947, -0.71877447345135, 0.625224632383091,
-1.78899598306442, -0.793441090906698, -1.09210755738336, 1.32211305639179,
-1.96321808990278, -1.51521838684306, 0.00549171084843096, -2.9911285157337,
0.276780418706376, -2.1225068715777, -1.56499613237074, -0.683930051414732,
0.271802645324263, 0.398636337390084, -0.270774772063992, 0.662607717406351,
1.26287754043467, -0.00695272427921605, 0.459290519580567, -0.0828886740640689,
-0.779976209944577, 0.525669143000081, 1.64566839646848, -0.527130156430866,
-1.99806251026703, 0.852509813910332, -1.05477425032805, 0.0726916665582448,
0.177224929323366, 0.824335611149109, -0.444996877229983, -0.0218860477702858,
-1.2713074392762, -0.270774772063992, -0.0467749213703124, 0.625224632383091,
-0.569441240213019, 0.722291233402677, 0.401224781689411, 0.127447185468045,
0.80442451260356, -0.594330112140679, 0.824335611149109, 0.276780418706376
), .Dim = c(50L, 5L), .Dimnames = list(c("CLR16", "CLR36", "CLR52",
"CLR56", "CLR20", "CLR22", "CLR11", "CLR14", "CLR17", "CLR33",
"CLR41", "CLR43", "CLR50", "CLR32", "CLR35", "CLR37", "CLR45",
"CLR48", "CLR49", "CLR5", "CLR55", "CLR58", "CLR59", "CLR6",
"CLR60", "CLR61", "CLR62", "CLR65", "CLR66", "CLR67", "CLR68",
"CLR7", "GGR70", "GGR77", "GGR71", "GGR69", "GGR72", "GGR73",
"GGR74", "GGR75", "GGR76", "GGR78", "GGR79", "GGR80", "GGR81",
"GGR83", "GGR84", "GGR85", "GGR87", "GGR89"), c("X88Sr_umol_molCa",
"X138Ba_umol_molCa", "X25Mg_umol_molCa", "X55Mn_umol_molCa",
"X7Li_umol_molCa")))
You can use labelsize = 0
as shown in the following code
library("factoextra")
# Data preparation
data("iris")
head(iris)
# Remove species column (5) and scale the data
iris.scaled <- scale(iris[, -5])
# K-means clustering
km.res <- kmeans(iris.scaled, 3, nstart = 25)
# Visualize kmeans clustering
fviz_cluster(km.res, iris[, -5], labelsize = 0) +
theme(legend.position = "none") + labs(title = "") +
theme(axis.title.x = element_text(margin = unit(c(3, 0, 0, 0), "mm")),
axis.title.y = element_text(margin = unit(c(0, 3, 0, 0), "mm")))
To remove all the little geometric shapes use geom = NULL
like
fviz_cluster(km.res, iris[, -5], geom = NULL, labelsize = 0) +
theme(legend.position = "none") + labs(title = "") +
theme(axis.title.x = element_text(margin = unit(c(3, 0, 0, 0), "mm")),
axis.title.y = element_text(margin = unit(c(0, 3, 0, 0), "mm")))
To remove cluster centers use show.clust.cent = F
fviz_cluster(km.res, iris[, -5], geom = NULL, labelsize = 0, show.clust.cent = F) +
theme(legend.position = "none") + labs(title = "") +
theme(axis.title.x = element_text(margin = unit(c(3, 0, 0, 0), "mm")),
axis.title.y = element_text(margin = unit(c(0, 3, 0, 0), "mm")))