1

I am having a very strange problem with my ggplot2 where I am trying to save a graph as a png using ggsave that contains a caption in the labs parameter. When I used a standard example posted on the web to use as a test and simple post to replicate here, I am getting the exact same error simply trying to display the graph - which is very strange it displays on my main code and only has this error with ggsave, but in my test it won't even display the graph.

This is my test code:

library(ggplot2)
ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(color = class)) +
  geom_smooth(se = FALSE, method = "loess") +
  labs(
    title = "Fuel efficiency generally decreases with engine size",
    subtitle = "Two seaters (sports cars) are an exception because of their light weight",
    caption = "Data from fueleconomy.gov"
  )

And the error I get with the code above is:

geom_smooth() using formula 'y ~ x' Error in titleGrob(label, x, y, hjust = hj, vjust = vj, angle = angle, : unused argument (expand_y = TRUE)

With my ggsave simply:

Warning: Error in titleGrob: unused argument (expand_y = TRUE)

I would be very grateful for some help. I have just updated to the latest version or R and all other packages associated with my code and this hasn't helped.

4

1 回答 1

0

我已经能够找出问题所在 - ggplot 和 ggtern 的代码用户和问题与干扰 ggtern 有关,我忘记了 ggplot2::ggsave。

许多人为创建这篇文章而道歉(这是出于绝望,但我终于想通了)。

于 2020-10-06T15:18:33.073 回答