Modify adjust Parameter of Existing Density Plot

14 views
Skip to first unread message

Dario Strbenac

unread,
Dec 22, 2015, 7:00:10 PM12/22/15
to ggplot2
How can I modify the adjust parameter of an existing plot? For example,

    library(ggplot2)
    specialPlot <- function(data, colours = c("red", "blue"))
    {
      ggplot(data, aes(x = values, colour = groups)) +
      stat_density(aes(y = ..density..), geom = "path", position = "identity") +
      scale_colour_manual("Group", values = c("red", "blue"))
    }

    aTable <- data.frame(values = rnorm(100), groups = sample(LETTERS[1:2], 100, replace = TRUE))
    thePlot <- specialPlot(aTable)

Now that the plot has been assigned to the variable thePlot, how can I make the bandwidth twice as large as the automatically-chosen bandwidth value by modifying thePlot, but not the function specialPlot, because the plotting function might be from a R package which I am not the author of?
Reply all
Reply to author
Forward
0 new messages