Reputation: 2703
I'm using the limits
under the scale_x_discrete
scale. Now I'm familiary with specifying which factors you want to take with through the limits
parameter in a normal way: e.g limit = c("x", "y")
But if I have a long list of factors, and want to negate say "x"
, I can't seem to find the right syntax (if this is even possible). I've tried scale_x_discrete(limits = -c("x"))
and other variations, but they have all generated errors. What is the right syntax?
Upvotes: 0
Views: 25
Reputation: 145965
If you really want to do this within the limits
argument, you could do it like this:
limits = setdiff(levels(your_data$your_x_variable), c("x", "other_level_to_omit"))
But I think the most natural way would be just to subset your data before plotting.
ggplot(your_data[your_data$your_x != "x", ], ...)
(or use subset
or dplyr::filter
or whatever idiom you prefer)
Upvotes: 1