admin管理员组文章数量:1277510
I cannot seem to be able to color the lines of different models with different colors in the following model:
library(modelsummary)
url <- '.csv'
dat <- read.csv(url)
# rescale mm -> cm
dat$bill_length_cm <- dat$bill_length_mm / 10
dat$flipper_length_cm <- dat$flipper_length_mm / 10
models <- list(
"Small model" = lm(bill_length_cm ~ flipper_length_cm, data = dat),
"Medium model" = lm(bill_length_cm ~ flipper_length_cm + body_mass_g, data = dat),
"Large model" = lm(bill_length_cm ~ flipper_length_cm + body_mass_g + species, data = dat))
modelplot(models, facet = TRUE)
which results in
I tried with
scale_fill_brewer(palette = "Set1", name = "term")
but doesn't seem to work
I cannot seem to be able to color the lines of different models with different colors in the following model:
library(modelsummary)
url <- 'https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv'
dat <- read.csv(url)
# rescale mm -> cm
dat$bill_length_cm <- dat$bill_length_mm / 10
dat$flipper_length_cm <- dat$flipper_length_mm / 10
models <- list(
"Small model" = lm(bill_length_cm ~ flipper_length_cm, data = dat),
"Medium model" = lm(bill_length_cm ~ flipper_length_cm + body_mass_g, data = dat),
"Large model" = lm(bill_length_cm ~ flipper_length_cm + body_mass_g + species, data = dat))
modelplot(models, facet = TRUE)
which results in
I tried with
scale_fill_brewer(palette = "Set1", name = "term")
but doesn't seem to work
Share Improve this question asked Feb 24 at 20:36 robertspierrerobertspierre 4,4303 gold badges41 silver badges63 bronze badges 01 Answer
Reset to default 3You can achieve your desired result by mapping model
on the color
aes. Afterwards you can set your desired colors using scale_color_brewer
or ...
library(modelsummary)
library(ggplot2)
modelplot(models, facet = TRUE) +
aes(color = model) +
scale_color_brewer(palette = "Set1")
本文标签: rDifferent colors for different models in faceted modelplotStack Overflow
版权声明:本文标题:r - Different colors for different models in faceted modelplot - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741242751a2364297.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论