0

Is it possible to plot a scatterplot with a smooth curve and confidence interval using rcharts?

I can do it with ggvis or ggplot2 but I think rcharts graphics look better in general.

This is an example with ggvis

library(ggvis)
mtcars %>% 
  ggvis(~wt, ~mpg) %>%
  layer_points() %>%
  layer_model_predictions(model = "lm", se = TRUE)

and this with ggplot2

library(ggplot2)
c <- ggplot(mtcars, aes(wt, mpg))
c + stat_smooth() + geom_point()

Thanks!

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
Ignacio
  • 7,646
  • 16
  • 60
  • 113
  • what library do you like best? I am working on adding layer functionality to rCharts + dimple. – timelyportfolio Jun 30 '14 at 14:43
  • rcharts>ggplot2>ggvis. But that could rapidly change. I'm more familiar with ggplot2 and I have barely use the others. When I'm able to create a graph with rcharts i love the end result. – Ignacio Jun 30 '14 at 14:55

1 Answers1

0

Have you tried Loess?

Description

Plot and add a smooth curve computed by loess to a scatter plot.

Usage

scatter.smooth(x, y = NULL, span = 2/3, degree = 1,
    family = c("symmetric", "gaussian"),
    xlab = NULL, ylab = NULL,
    ylim = range(y, pred$y, na.rm = TRUE),
    evaluation = 50, ..., lpars = list())

loess.smooth(x, y, span = 2/3, degree = 1,
    family = c("symmetric", "gaussian"), evaluation = 50, ...)

there is an example of such a chart here

loess

in rcharts you can use J4L

Cubic curves: the points you provide will be contained in the curve.

SERIE_TYPE_1=CURVE Use cubic natural curves

j4l

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81