We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
Drawing a line with stat_function for x as factor used to work in ggplot2_1.0.0 and ggplot2_1.0.1. Doesn't work in ggplot2_2.0.0:
ggplot(iris,aes(x=factor(Species),Petal.Length)) + geom_violin() + stat_function(fun=function (x) as.numeric(x)^2, colour="red")
This works in ggplot2_2.0.0, but the x labels need fixing:
ggplot(iris,aes(x=as.numeric(Species),Petal.Length,group=as.numeric(Species))) + geom_violin() + stat_function(fun=function (x) as.numeric(x)^2, colour="red")
The text was updated successfully, but these errors were encountered:
It’s worth noting that the x labels cannot be fixed by adding a scale_x_discrete — this will result in the same error as when passing a categorical variabel to the function.
However, using a scale_x_continuous works:
aes(as.numeric(Species), Petal.Length, group = Species) +
stat_function(fun = function (x) as.numeric(x) ^ 2, color = "red") +
breaks = seq_len(nlevels(iris$Species)),
labels = levels(iris$Species))
Sorry, something went wrong.
No branches or pull requests