问题
Please find My Data
below. I have the following plot
I want to apply the "jco"-palette (or just manually typing a "#xxxxxx"-color). However, I cant make it work. I have tried
library(ggplot2)
library(ggsci)
ggplot(Predict(model, ref.zero = TRUE, fun=exp)) + scale_color_jco() + scale_fill_jco()
How can I
1) Manually change the color to #xxxxxx?
2) Apply the JCO-palette?
My Data
library(rms)
model <- cph(Surv(Follow.up.death,Death)~rcs(total.mbq),data=w)
w <- structure(list(Follow.up.death = c(18, 2, 14, 17, 31, 4, 20,
15, 12, 19, 10, 17, 27, 22, 3, 43, 24, 14, 13, 5, 12, 137, 22,
87, 48, 24, 72, 32, 14, 83, 68, 56, 57, 18, 16, 70, 1.9, 69.2,
126.3, 41.6, 17.9, 1.3, 87.4, 4.4, 137.4, 17.5, 95.8, 65.2, 14.8,
98.5, 16.6, 74.9, 10.3, 43.4, 32.5, 4.8, 7.3, 107.8, 6.8, 18.3,
33, 25.2, 49.2, 15.9, 1.2, 42.7, 1, 9, 1.8, 15.6, 8.9, 15, 16.4,
7.7, 75.5, 12.2, 54.8, 22.2, 9.7, 14.3, 5.2, 64.5, 21.8, 0.2,
7.3, 18.7, 5.1, 17.3, 27.4, 16, 24.2, 9.7, 8.2, 5.7, 41.8, 10.6,
22.8, 4.8, 6, 4, 50, 21, 30, 5, 11, 12), Death = c(0L, 1L, 1L,
0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L,
1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L), total.mbq = c(29354L, 7445L, 22309L,
29699L, 29711L, 14765L, 22257L, 29715L, 29772L, 13320L, 20905L,
12950L, 3400L, 14800L, 7400L, 21890L, 19400L, 14800L, 14700L,
22200L, 1688L, 4500L, 8438L, 13500L, 14800L, 12580L, 12950L,
13320L, 11840L, 13320L, 14800L, 13690L, 11250L, 12210L, 13320L,
13320L, 14800L, 12580L, 20720L, 11840L, 14800L, 7030L, 14800L,
14800L, 8325L, 11100L, 10730L, 13690L, 12210L, 14800L, 13320L,
14800L, 12950L, 22200L, 17945L, 22200L, 8140L, 13690L, 11581L,
14430L, 13320L, 13320L, 21090L, 11100L, 3885L, 6475L, 6660L,
6660L, 5920L, 7500L, 5000L, 12500L, 12500L, 10000L, 12500L, 7500L,
15000L, 10000L, 5000L, 7500L, 5000L, 15000L, 12500L, 7500L, 7500L,
7500L, 5000L, 10000L, 10000L, 10000L, 12500L, 5000L, 5000L, 10000L,
12500L, 5000L, 10000L, 10000L, 22200L, 14800L, 29000L, 14000L,
4800L, 21600L, 28800L, 11400L)), .Names = c("Follow.up.death",
"Death", "total.mbq"), class = "data.frame", row.names = c(NA,
-106L))
来源:https://stackoverflow.com/questions/54534799/why-does-ggplot-predict-not-change-color-palette-in-r