0
votes

I need to make the second x axis according to the first axis that is day of year. but i have the error of Discrete value supplied to 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)))
1

1 Answers

0
votes

I'm not entirely sure what you're trying to do, but the factor(Alt) makes your x field discrete. Try removing that so your code should look like:

g.b <- ggplot(CDD, aes(Alt, b))