# Problems in using cox regression with restricted cubic spline plot with R software

In R software, I want to plot a graph by using cox regression with the restricted cubic spline method. However, I can't quite get it to work.

This is the code I'm using:

library(rms); require(rms); library(Hmisc)
d<-curve.men
fit <- cph(Surv(time,death) ~ rcs(bmi,4)
+ systolic +glucose + l_chol + age
+ edu_g2 + smoke_s + l_chol + drink + activity_l+activity_w,
data=d, nk=5)
plot(Predict(fit,bmi), xlab="bmi", ylab="Relative Risk", lty=1, lwd=2)


Which creates the following plot (A):

However, I want to plot the following graph (B):

1. How do I set the reference point? (for example: bmi = 24.21429 as the reference point)
2. I want to add the horizontal line. I tried using abline(h=1), but it did not work.
3. All in all, how do I make the graph look like (B)?
• in graph (A), y range is -1.0 ~ 1.5, – Xudong Liu Jan 13 '16 at 8:25
• Welcome to Computer Graphics SE! I tried to improve the readability of your post a bit. However, I'm not sure it's a great fit for this site. You could probably just ask this on Stack Overflow instead. I've started a discussion on meta whether questions about plotting simple graphs are considered on topic or not. – Martin Ender Jan 13 '16 at 12:42
• Given that this is specifically about R, it's likely a better fit for Cross Validated. – Nathan Reed Jan 14 '16 at 0:02
• After discussion, the consensus seems to be that questions about plotting are off-topic. computergraphics.meta.stackexchange.com/questions/205/… – Julien Guertault Dec 23 '18 at 17:35