Hi,
I've got a ggplot that uses log(x) for the y-axis. Y values ranging from >0 to <20,000 so log(y) roughly between -10 and +10.
What I want is to use the log(y) values to plot, but to use the (raw) Y values for the y-axis labels.
I've looked at the ggplot2 options and the scales package, but for the life of me I can't seem to get it working. Any suggestions?
This is my ggplot command (with the default log(y) labels):
tryCatch(
{ #This is the Try section
plotthis <- toplot() #Get the data to plot
p <- ggplot(data = plotthis, aes(x = age, y = nfl, fill = diagnosis)) + #init the plot object and (aestatically) map (aes) the data to internal variables x and y
#prediction interval
geom_line(aes(y=lwr, linetype = diagnosis)) + #draw lower prediction interval line - remove linetype here and set to ggplot aes to also change the regres linetype
geom_line(aes(y=upr, linetype = diagnosis)) + #draw higher prediction interval line
geom_ribbon(aes(ymin = lwr, ymax = upr, fill = diagnosis), alpha = 0.5) + #"grey70"
#regression line
geom_smooth(aes(color = diagnosis), method=lm, se=FALSE, size = 0.5) + #show regression line with confidence area
#overrides
scale_color_manual(values = line_colors) +
scale_linetype_manual(values = line_types) +
scale_fill_manual(values = fill_colors) +
#patient info
geom_point(aes(x=input$patient_age, y=log(input$patient_nfl), size = 3), colour="blue") + #add the patient point
#layout
xlab(xlab) +
ylab(ylab) +
guides(colour = guide_legend("Selected diagnosis"), fill = guide_legend("Selected diagnosis"), linetype = guide_legend("Selected diagnosis")) +
guides(size = FALSE) + #remove size (dot) from legend
xlim(adjusted_minx(),adjusted_maxx()) + #set x axis range
theme(legend.position = "bottom")
plot(p)
},
error=function(cond){
showNotification("Invalid combination of choices. Resetting interface.", type = "error", closeButton = TRUE)
#message(cond)
resetall()
# Choose a return value in case of error
return(NA)
},
finally={
#message("Some other message at the end")
}
)
})