Reputation:
Currently, I wish to produce a smooth curve in the ggplot2. To give a proper view of the data, I need to limit the domain of the x-axis and log the scale for the x-axis. My code is as follows:
sample <- ggplot(x, aes(abc, xyz)) +
scale_x_log10() +
scale_x_continuous(1,10000) +
#xlim(1, 10000)
### attempted xlim as opposed to scale_x_continuous with the same
### result.
The warning I receive is as follows, "Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale."
Basically, I get to choose one or the other function.
Is there a mechanism to log the x-axis scale and also set the domain for be 1 to 10,000 without one one function overriding the other?
If you require more details, please feel free to comment. I have attempted to research a similar question to no avail, so if you find this to be a duplicate, do not hesitate to mark it as such.
Upvotes: 0
Views: 798
Reputation: 5018
library(ggplot2)
x <- data.frame(abc = runif(1000, 1, 100000),
xyz = runif(1000, 1, 10))
ggplot(x, aes(abc, xyz)) +
geom_point()
ggplot(x, aes(abc, xyz)) +
geom_point() +
scale_x_log10(limits = c(1, 10000))
#> Warning: Removed 927 rows containing missing values (geom_point).
Upvotes: 0