Skip to content

Commit 1b2bad6

Browse files
committed
fixed plot label sizes on iteration plots
1 parent e20c388 commit 1b2bad6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

clustering.Rmd

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ for (i in 1:4) {
469469
stroke = 1,
470470
color = "black",
471471
fill = cbpalette) +
472-
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i))
472+
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i), size = 5)+
473+
theme(text = element_text(size = 14))
473474
474475
if (i == 1 | i == 2) {
475476
plt_ctr <- plt_ctr +
@@ -502,7 +503,8 @@ for (i in 1:4) {
502503
stroke = 1,
503504
color = "black",
504505
fill = cbpalette) +
505-
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i))
506+
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i), size = 5)+
507+
theme(text = element_text(size = 14))
506508
507509
if (i == 1 | i ==2) {
508510
plt_lbl <- plt_lbl +
@@ -613,7 +615,7 @@ Figure \@ref(fig:10-toy-kmeans-bad-iter) shows what the iterations of K-means wo
613615

614616
(ref:10-toy-kmeans-bad-iter) First five iterations of K-means clustering on the `penguin_data` example data set with a poor random initialization. Each pair of plots corresponds to an iteration. Within the pair, the first plot depicts the center update, and the second plot depicts the reassignment of data to clusters. Cluster centers are indicated by larger points that are outlined in black.
615617

616-
```{r 10-toy-kmeans-bad-iter, echo = FALSE, warning = FALSE, fig.height = 6.75, fig.width = 8, fig.align = "center", fig.cap = "(ref:10-toy-kmeans-bad-iter)"}
618+
```{r 10-toy-kmeans-bad-iter, echo = FALSE, warning = FALSE, message = FALSE, fig.height = 6.75, fig.width = 8, fig.align = "center", fig.cap = "(ref:10-toy-kmeans-bad-iter)"}
617619
list_plot_cntrs <- vector(mode = "list", length = 5)
618620
list_plot_lbls <- vector(mode = "list", length = 5)
619621
@@ -640,7 +642,8 @@ for (i in 1:5) {
640642
stroke = 1,
641643
color = "black",
642644
fill = cbpalette) +
643-
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i))
645+
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i), size = 5) +
646+
theme(text = element_text(size = 14))
644647
645648
if (i == 1 | i == 2) {
646649
plt_ctr <- plt_ctr +
@@ -672,7 +675,8 @@ for (i in 1:5) {
672675
stroke = 1,
673676
color = "black",
674677
fill = cbpalette) +
675-
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i))
678+
annotate("text", x = -0.5, y = 1.5, label = paste0("Iteration ", i), size = 5) +
679+
theme(text = element_text(size = 14))
676680
677681
if (i == 1 | i == 2) {
678682
plt_lbl <- plt_lbl +
@@ -690,10 +694,10 @@ iter_plot_list <- c(list_plot_cntrs[1], list_plot_lbls[1],
690694
list_plot_cntrs[5], list_plot_lbls[5])
691695
692696
ggarrange(iter_plot_list[[1]] +
693-
theme(axis.text.x = element_blank(),
697+
theme(axis.text.x = element_blank(), #remove x axis
694698
axis.ticks.x = element_blank(),
695699
axis.title.x = element_blank(),
696-
plot.margin = margin(r = 2, b = 2)),
700+
plot.margin = margin(r = 2, b = 2)), # change margins
697701
iter_plot_list[[2]] +
698702
theme(axis.text.y = element_blank(),
699703
axis.ticks.y = element_blank(),
@@ -740,15 +744,15 @@ ggarrange(iter_plot_list[[1]] +
740744
axis.ticks.y = element_blank(),
741745
axis.title.y = element_blank(),
742746
plot.margin = margin(l = 2, t = 2, b = 2)),
743-
ggplot() + theme_void(), ggplot() + theme_void(), ggplot() + theme_void(), ggplot() + theme_void(),
747+
ggplot() + theme_void(), ggplot() + theme_void(), ggplot() + theme_void(), ggplot() + theme_void(), # adding third row of empty plots to change space between third and fourth row
744748
iter_plot_list[[9]] +
745749
theme(plot.margin = margin(r = 2)),
746750
iter_plot_list[[10]] +
747751
theme(axis.text.y = element_blank(),
748752
axis.ticks.y = element_blank(),
749753
axis.title.y = element_blank(),
750754
plot.margin = margin(l = 2) ),
751-
heights = c(4, 4, -1, 4),
755+
heights = c(3, 3, -1, 3),
752756
ncol = 4)
753757
```
754758

0 commit comments

Comments
 (0)