0

This was not happening before, and then at some point my size function just kind of broke to the point where any attempt to specify size causes the images to inflate to a ridiculous size. Here is the code where I set the size to .1:

G <- ggplot(G1, aes(x=Week, y=YPA)) +
  geom_hline(yintercept=7.4, linetype="dotted") +
  geom_segment(mapping=aes(x=1, xend=1, y=6.2, yend=7.8), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=3, xend=3, y=7.730769231, yend=7.2), linetype="longdash", color = "red") +
  geom_segment(mapping=aes(x=4, xend=4, y=5, yend=7), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=5, xend=5, y=7, yend=8.4), linetype="longdash", color = "red") +
  geom_segment(mapping=aes(x=6, xend=6, y=5.5, yend=8), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=7, xend=7, y=5.5, yend=6.5), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=9, xend=9, y=8.3, yend=9), linetype="longdash", color = "red") +
  geom_segment(mapping=aes(x=10, xend=10, y=6.689655172, yend=8), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=11, xend=11, y=3.095238095, yend=6.2), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=12, xend=12, y=6.46875, yend=8.1), linetype="longdash", color = "green") +
  geom_segment(mapping=aes(x=13, xend=13, y=8.518518519, yend=8), linetype="longdash", color = "red") +
  labs(title = "\nOU Opponent Passing Efficiency By Week - 2019\n",
       y = "\nYards per Pass Attempt", x="Week\n",
       caption = "Figure: @stevenplai | Data: ESPN | Images: ESPN") + 
  theme_minimal() +
  theme(
    plot.title = element_text(size=40, face = "bold", family = "Helvetica"),
    plot.subtitle = element_text(size=25, family = "Helvetica"),
    axis.ticks = element_line(),
    axis.text = element_text(size=15),
    axis.title = element_text(size=30),
    plot.caption = element_text(size=20, family = "Helvetica"),
    legend.position = "none",
  ) +
  scale_x_continuous(labels = c(1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, "CC"),
                     breaks=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) +
  scale_y_continuous(labels = c(4,5,6,7,"FBS Avg",8,9),
                     breaks=c(4,5,6,7,7.4,8,9)) +
  geom_image(mapping=aes(image=logo, size=.1))

This is the graph that that code produces

And this is what it produces if I simply remove the "size=.1" from the final line of code

Second image is much closer to what I want, but the images are a bit too small and as of now I'm not able to change the size.

This has never happened to me before and it wasn't happening earlier, so I'm sure I just did something dumb. Thank you in advance for your help.

Sidenote: this is a separate question but I'm going to ask anyway because this seems like a simple thing. Does anyone know how to tint/fade one of the images in each X value? Nothing that I've tried seems to work.

1 Answers1

2

Only put mappings for data columns inside aes(). For a constant like size = 0.1, put that outside aes().

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294