Skip to content

Confidence band extending too far left #453

New issue

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? Sign in to your account

Closed
corinne-riddell opened this issue Feb 5, 2016 · 1 comment
Closed

Confidence band extending too far left #453

corinne-riddell opened this issue Feb 5, 2016 · 1 comment

Comments

@corinne-riddell
Copy link

One more for you... In the Nunavut panel (bottom right) - the data begins only at 2003 (unlike the other provinces that begin at 2002), but for some reason the confidence band extends to cover 2002 even though there is no data at 2002 in Nunavut.

problem

Here's the code for you. The ggplot is called plot1 and the plotly version is called gg2. Thanks!

library(ggplot2)
library(scales)
library(grid)
library(dplyr)
library(plotly)
dat <- read.csv("http://corinne-riddell.github.io/datasets/CS_graph.csv")
dat$ucl2 <- as.numeric(as.character(dat$ucl))
dat$lcl2 <- as.numeric(as.character(dat$lcl))

order <- dat %>% group_by(Label) %>% dplyr::summarise(Code=first(Code))

dat$CS2 <- dat$CS/100

dat$Lab2 <- factor(dat$Label, levels=c("Canada","Newfoundland and Labrador",
                                       "Prince Edward Island","Nova Scotia",
                                       "New Brunswick", "Quebec", "Ontario",
                                       "Manitoba", "Saskatchewan", "Alberta",
                                       "British Columbia", "Yukon Territory",
                                       "Northwest Territories", "Nunavut"
                                       ))

plot1 <- ggplot(dat, aes(x=Year, y=CS2)) + geom_ribbon(aes(ymin=lcl2/100, ymax=ucl2/100), col="#f0f0f0", alpha=0.5) +
  geom_point() + geom_line(lwd=0.5) + facet_wrap(~Lab2, ncol=4) +
  theme_minimal(base_size=15) + scale_y_continuous(labels=percent, name="Cesarean delivery rate (%)\n") +
  scale_x_continuous(name="\nYear") + theme(panel.border = element_rect(fill=NA))
plot1

gg2 <- ggplotly(plot1)
gg2
@cpsievert
Copy link
Collaborator

This should be fixed in f1900cc. Let us know if you still have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants