-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set manual color for only one line #60
Comments
To follow-up, say I'd like to manually set one subgroup (female) to black. ` plot_cutpointr(opt_cut, xvar = cutpoint, ` Any advice is greatly appreciated. |
Hi Jian, I think your first approach isn't so bad. You just need a function that generates the color palette. I think there are many options to do that in R. Here, I am using Can you try this? It's a bit hacky, but I think it should pick the correct subgroup for the manually set color. Can you confirm that?
If you need more control or want to try plotting the data with a manual call to ggplot, you could extract the plotted data with Also, thanks for drawing my attention to the problems with |
Thanks very much Christian. This is a perfect solution. I will go ahead to close this issue. One very minor observation with regard the "New names during the run."
` Running bootstrap... |
Dear Christian @Thie1e
I ran cutpointr with subgroup and bootstrap. Then I draw lines corresponding to each subgroup. Because one of the lines is my reference so I'd like to set a color for only this line. To illustrate what I try to achieve, I use the sample dataset as following. As shown, I am able to manually set two colors for gender. However, what I really want is to continue using default color for all lines except my reference line. The reason is that I will have many lines (subgroup) and I'd like to see clearly my reference line among the rest of the lines.
Any advice how I can achive this?
Thanks much.
`
library(cutpointr)
library(dplyr)
library(ggplot2)
data(suicide)
opt_cut <- cutpointr(data=suicide, x=dsi, class=suicide, direction = ">=", pos_class = "yes",
neg_class = "no", subgroup = gender,
method = maximize_metric, metric = youden,
boot_runs = 100) %>%
add_metric(list(cohens_kappa))
plot_cutpointr(opt_cut, xvar = cutpoint,
yvar = cohens_kappa,
conf_lvl = 0.95,
aspect_ratio = NULL) +
scale_x_continuous(n.breaks=20, minor_breaks = waiver()) +
scale_y_continuous(n.breaks=5, minor_breaks = waiver()) +
scale_color_manual(values = c("#353436",
"#02e302")) +
scale_fill_manual(values = c("#353436",
"#02e302"))
`
The text was updated successfully, but these errors were encountered: