Rendering issue with the PDF viewer RStudio pops up after knitting

I am running into a PDF rendering issue when constructing a nice histogram faceted by category with a shadow version of the non-facected data in each facet graph.

I wanted to know if anybody else has seen this and if there is a fix or work-around.

If I do this in an HTML RMarkdown document it renders correctly. The same code in a PDF RMarkdown document incorrectly places a colored bordered at the count=0 level of each facet (which I consider incorrect, for large count situations, where I am actually using this, this would seem to indicate there is a small but non-zero amount of data in the histogram bins in question) when viewed by the viewer that RStudio pops up. This mis-rendering happens only on the viewer that RStudio brings up during the render, the produced PDF does have a correct graph (working on OSX).

Incorrect viewer render:


Correct render in PDF document:

Example RMarkdown:

title: "LineIssuePDF"
output: pdf_document


d <- data.frame(x = 1:10,
                c = c(rep("A", 3), rep("B", 4), rep("A", 3)),
                stringsAsFactors = FALSE)

bins <- 5
binwidth <- NULL
dthin <- d
dthin$c <- NULL

ggplot(d, aes(x=x)) +
  geom_histogram(data = dthin, bins = bins, binwidth = binwidth,
                 fill="lightgray", color = "lightgray", alpha = 0.5) +
  geom_histogram(data = d, aes(fill=c), color = NA,
                 bins = bins, binwidth = binwidth) +
  facet_wrap(~c, ncol=1, labeller = label_both) +
  guides(fill = FALSE) +
  ggtitle("incorrect result: colored lines/borders in PDF render (does not happen in HTML))")