I am familiar with transforming my secondary y axis values in ggplot, however, I am unable to set a custom range for the min and max values. I would ultimately like to set the second y axis range values to a min of 40 and a max of 80. my first y variable has a range (0,108) and my second y variable has a range (47.44 - 71.17). In plot 1 we have a one to one transformation where I have the range going from a min of 0 to a max of 90. the code to produce this is
geom_line(aes(x=DATE, y = value/.75,colour= variable), size= 2)
and subsequently
scale_y_continuous(expand=c(0,0),
breaks = seq(0,120, by = 20),
label = comma,
sec.axis = sec_axis(~.*.75,
breaks= seq(0,90,by=10),
name = "Temperature (°F)"),
limits = c(0,120))
transformed second axes min 0 max 90
I have also tried this script to no avail
geom_line(aes(x=DATE, y = (value-40)/.75,colour= variable), size= 2)
and subsequently
scale_y_continuous(expand=c(0,0),
breaks = seq(0,120, by = 20),
label = comma,
sec.axis = sec_axis(~.*.75+40,
breaks= seq(40,80,by=10),
name = "Temperature (°F)"),
limits = c(0,120))
which produces plot 2
transformed second axes min 40 to max 80
thanks in advance for any help with this