Setting Axis Limits on ggplot Charts

I’ve been doodling some chart in R/ggplot using geom_text() to generate a labelled scatterplot.

The chart actually builds up several layers using different datasets, so it’s not obvious how to set the ranges cleanly: I know the lower bound I want for the y-axis (y=0), but I want to let the upper bound float.

There’s also an issue with the labels overflowing the edges left and right.


So here are a couple of lines to make everything better (chart is in g):

#Find the current ymax value for upper bound
#(via )

#Handle the overflow by expanding the x-axis