Error in axis(side = 1, at = 1:10, seq(0.1, 1, 0.1)) : plot.new has not been called yet

Hi i'm trying to draw ggplot by using under code.

d1 %>% ggplot(aes(sift_n, poly_n, col = poly_c)) + geom_point() + axis(side = 1, at = 1:10, seq(0.1, 1.0 ,0.1))

I use axis to edit my axis, but I get error message like this:
Error in axis(side = 1, at = 1:10, seq(0.1, 1, 0.1)) : plot.new has not been called yet

what should I do?

You can't mix base R plot commands with ggplot2 commands. To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

I'm sorry, but I'm now trying replex, and have little problem.
Am I shoule copy all codes and run reprex() or just copy error code? Because just before I copy all codes and run reprex(), and now my rstudio cloud is keep loading..

You have to copy the necessary code to reproduce your issue, for example, I think this is similar to what you are trying to achieve.

library(ggplot2)

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
    geom_point() +
    scale_x_continuous(breaks = 1:8, labels = seq(0.1, 0.8 ,0.1))

Created on 2019-10-16 by the reprex package (v0.3.0.9000)

thanks, i understand. and really sorry but now in my console, the blue word 'selection:' is not deleted. i can't erase this by backspace and i don't know why it appeared...

That comes from reprex() function and is asking you to choose an option, type 2 and then Enter

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.