Spaces:
Runtime error
Runtime error
Update app.R
Browse files
app.R
CHANGED
|
@@ -504,7 +504,7 @@ server <- function(input, output,session) {
|
|
| 504 |
geom_text(aes(x = 103, label = value),
|
| 505 |
hjust = 0, size = 6, family = "roboto") +
|
| 506 |
geom_point(aes(x = percentile, color = "white", fill = color),
|
| 507 |
-
size =
|
| 508 |
geom_text(aes(x = percentile, label = percentile),
|
| 509 |
size = 6, color = "white", fontface = "bold", family = "roboto") +
|
| 510 |
scale_x_continuous(limits = c(-16, 113), expand = c(0, 0)) +
|
|
@@ -547,35 +547,21 @@ server <- function(input, output,session) {
|
|
| 547 |
caption_grob <- textGrob("Viz by: @TimStats | tim-stats.com | Data: MLB",gp = gpar(fontsize = 15, fontface = "bold",
|
| 548 |
fontfamily = "roboto"))
|
| 549 |
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
plot_width <- 1000
|
| 553 |
-
plot_height <- 1000
|
| 554 |
-
|
| 555 |
-
# Create a viewport with fixed dimensions
|
| 556 |
-
grid.newpage()
|
| 557 |
-
pushViewport(viewport(width = unit(1, "npc"), height = unit(1, "npc")))
|
| 558 |
-
|
| 559 |
-
# Adjust the layout heights to be proportional
|
| 560 |
-
layout_heights <- c(0.15, 0.05, 0.75, 0.05)
|
| 561 |
-
|
| 562 |
-
# Create the final plot with fixed dimensions
|
| 563 |
-
final_plot <- arrangeGrob(
|
| 564 |
title_with_logo,
|
| 565 |
labels_plot,
|
| 566 |
main_plot,
|
| 567 |
caption_grob,
|
| 568 |
-
heights =
|
| 569 |
)
|
| 570 |
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
|
|
|
| 575 |
)
|
| 576 |
-
|
| 577 |
-
# Draw the plot in the viewport
|
| 578 |
-
grid.draw(padded_plot)
|
| 579 |
}, height = 1000, width = 1000, res = 96)
|
| 580 |
}
|
| 581 |
|
|
|
|
| 504 |
geom_text(aes(x = 103, label = value),
|
| 505 |
hjust = 0, size = 6, family = "roboto") +
|
| 506 |
geom_point(aes(x = percentile, color = "white", fill = color),
|
| 507 |
+
size = 8, shape = 21, stroke = 1) +
|
| 508 |
geom_text(aes(x = percentile, label = percentile),
|
| 509 |
size = 6, color = "white", fontface = "bold", family = "roboto") +
|
| 510 |
scale_x_continuous(limits = c(-16, 113), expand = c(0, 0)) +
|
|
|
|
| 547 |
caption_grob <- textGrob("Viz by: @TimStats | tim-stats.com | Data: MLB",gp = gpar(fontsize = 15, fontface = "bold",
|
| 548 |
fontfamily = "roboto"))
|
| 549 |
|
| 550 |
+
# Final arrangement with logo in title
|
| 551 |
+
final_plot <- grid.arrange(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
title_with_logo,
|
| 553 |
labels_plot,
|
| 554 |
main_plot,
|
| 555 |
caption_grob,
|
| 556 |
+
heights = c(0.15, 0.05, 0.75, 0.05)
|
| 557 |
)
|
| 558 |
|
| 559 |
+
grid.arrange(
|
| 560 |
+
gtable_add_padding(
|
| 561 |
+
final_plot,
|
| 562 |
+
padding = unit(c(20, 20, 20, 20), "points") # top, right, bottom, left margins
|
| 563 |
+
)
|
| 564 |
)
|
|
|
|
|
|
|
|
|
|
| 565 |
}, height = 1000, width = 1000, res = 96)
|
| 566 |
}
|
| 567 |
|