3

I would like to reproduce the ggplot style of showing a confidence interval around a value with a ribbon, like geom_ribbon or geom_smooth.

I tried calculating the confidence interval separately and plotting with fill_between() which is close but doesn't seem exactly right. How can the x axis be the style that comes from plot_date() while using fill_between()? What about smoothing of the ribbon?

Example output:

enter image description here enter image description here

The ggplot code looks like this (several found examples):

qplot(wt, mpg, data=mtcars, colour=factor(cyl)) +
  geom_smooth(aes(ymin = lcl, ymax = ucl), data=grid, stat="identity")

ggplot(answers.overall, aes(Date, Answers)) + geom_line() + 
  geom_smooth(method="loess") + theme(axis.text.x = element_text(angle = 45, hjust = 1))

1 Answer 1

3

Is there a reason why you can't use ggplot for Python? Because that would really simplify things a lot:

import ggplot as gg

mtcars = gg.mtcars
gg.qplot(mtcars.wt, mtcars.mpg) + gg.geom_smooth(color="blue")
4
  • 1
    I just wasn't aware that it exists :) Thanks!
    – Alex I
    Jun 3, 2014 at 8:30
  • 1
    ggplot I think doesn't work with the latest pandas now Mar 18, 2019 at 16:24
  • @IlayaRajaS Thanks for the info. Do you know how long it has been since ggplot stopped working? As an aside, one reason I moved away from Python for Data Analysis is because it seemed like every time I'd update my packages something would break.
    – Steve S
    Mar 21, 2019 at 15:15
  • There is a fix for that ggplot issue, albeit a manual one: github.com/yhat/ggpy/issues/662#issuecomment-484138308
    – Zak Kann
    Oct 28, 2019 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.