Skip to content

Computation failed in stat_function() for non-numeric values of x #1509

Closed
@atfg

Description

@atfg

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions