r - adding second x axis to boxplot in ggplot -
i need make second x axis according first axis day of year. have error of discrete value supplied continuous scale.
b alt 148 1300 122 1300 130 1300 250 2000 300 2000 244 2000 `` monthid <- c("jan", "feb", "mar", "apr", "may", "jun", "jul", "agu", "sep", "oct", "nov", "dec") firstday <- c(1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335,365) middleday <- c(16, 45, 75, 105, 136, 166, 197, 228, 258, 289, 319, 350) g.b <- ggplot(cdd, aes(factor(alt), b)) g.b+ scale_x_continuous(breaks = unique( middleday), sec.axis = sec_axis(~ ., breaks = unique( middleday)))
i'm not entirely sure you're trying do, factor(alt) makes x field discrete. try removing code should like:
g.b <- ggplot(cdd, aes(alt, b))
Comments
Post a Comment