I've noticed an unexpected difference in the rendering of a ggplot between local output and a Shiny application. The axes labels are entirely different:
The axes of the two plots differ by exactly 1 day - how very odd! What happened during the publishing to Shiny process?
Data
data.df <- structure(list(Report.Date = structure(c(1430434800, 1433026800,
1435618800, 1438297200, 1440975600, 1443567600, 1430434800, 1433026800,
1435618800, 1438297200, 1440975600, 1443567600), tzone = "", class = c("POSIXct",
"POSIXt")), variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("Datasets.Deposited", "Datasets.Published"
), class = "factor"), value = c(0L, 21L, 32L, 43L, 56L, 73L,
0L, 4L, 9L, 21L, 29L, 49L)), .Names = c("Report.Date", "variable",
"value"), row.names = c(NA, -12L), class = "data.frame")
Local code
library(ggplot2)
library(scales)
base <- ggplot(data.df, aes(Report.Date, value))
plot <- base + geom_area(aes(group = variable, fill= variable), position = 'identity') + geom_point(aes(color = series), color = "black")
plot <- plot + xlab("Date") + ylab("Number of Deposits/Published")
plot +
scale_y_continuous(breaks = seq(0,round(max(data.df$value)+5,-1),5)) +
scale_x_datetime(breaks = date_breaks("1 month"), labels = date_format("%Y-%b-%d"), minor_breaks = "1 month") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Shiny
ui.R
shinyUI(
fluidPage(
plotOutput("plot")
)
)
server.R
library(ggplot2)
library(scales)
shinyServer(
function(input, output){
output$plot <- renderPlot({
data.df <-
base <- ggplot(data.df, aes(Report.Date, value))
plot <- base + geom_area(aes(group = variable, fill= variable), position = 'identity') + geom_point(aes(color = series), color = "black")
plot <- plot + xlab("Date") + ylab("Number of Deposits/Published")
plot +
scale_y_continuous(breaks = seq(0,round(max(data.df$value)+5,-1),5)) +
scale_x_datetime(breaks = "1 month", labels = date_format("%d-%b-%Y"), minor_breaks = "1 month") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
}
)
}
)

