ggplot: modify coord_cartesian() values dynamically

Viewed 512

Is there a way to modify the plot coordinates using coord_cartesian() in a way that is dynamic based on the data in the ggplot call?

For example:

ggplot(cars, aes(x = speed, y = dist)) + 
geom_point() + 
coord_cartesian(xlim = c(min(.$speed), max(.$speed) + 10))

This doesn't work, nor does using .data$speed.

2 Answers
Related