为什么会这样/如何解决这个问题? iv阅读了有关此错误的其他一些条目,但仍然感到困惑,特别是因为当我运行下面的代码时,如果不使用粗体部分,它可以很好地运行,但是如果包含了粗体部分,则会出现此错误。
代码:
ggplot(diamonds, aes(x = price)) + geom_histogram(binwidth = 500) +
axis(side = 1, at = seq(0, 20000, by = 500))
错误:
Error in axis(side = 1, at = seq(0, 20000, by = 500)) :
plot.new has not been called yet
axis
是图形包而非ggplot的一部分。因此,axis
正在寻找plot
而不是ggplot
。