'How to show only a part of a plot of hazard ratio vs continuous variable?

Using the rms package and ggplot, I made a plot showing the hazard of a primary outcome vs a continuous variable (vdmr) using the code below (first image).

dd <- datadist(dat); options(datadist='dd')
spline <- cph(Surv(time, status) ~ rcs(vdmr, 4), data=dat)
ggplot(Predict(spline))

I would like to restrict the plot to only display the curve within a specific x-range (say, between 50 and 250; second image) but only after all values have been used to calculate the curve. This is similar to using xseq when applying it to geom_smooth, but I can't figure out how to integrate it in this context (outside of hacking it using photoshop). I'd appreciate any help.

Current plot

My goal



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source