I am preparing forest plots with regression coefficients using sjPlot
package. How can I customize the line color of regression coefficients to have one color for each coefficient?
I have tried to use the argument colors = c("blue", "red", "black")
within the plot_model function
, but it did not work. I have also tried to use different palettes combined with scale_color_manual
, but it did not work either.
Here is an example from sjPlot
package:
library(sjPlot)
library(sjmisc)
data(efc)
#I used log before each predictor to have an example of confidence interval
fit <- lm(tot_sc_e ~ log(c161sex) + log(e17age) + log(c160age), data = efc)
plot_model(fit, colors = c("blue", "red", "black"))
It gives me a plot with two blue lines and one red line. No black line in the plot!
Trying to use other ways did not help:
plot_model(fit, colors = NULL)+
scale_fill_sjplot(palette = "viridis", discrete = TRUE)+
scale_color_viridis(discrete = TRUE)
It actually uses the viridis palette, but again, two purple lines and one yellow line. And it returns the following messages:
"Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale." "Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale."
If I set colors = NULL
in the code, it should not return these messages, should it?
I would appreciate any help to get one different color for each predictor. Note: this plot will be combined with other plots with the same predictors. Therefore, I want to have them with the same color in both plots to improve the readability.