私は多くのプロットを作成しており、geom_text
呼び出しごとにcolor
引数を渡さなくても、データラベルのデフォルトの色を設定したいと考えています。私はプロットのタイトルと軸についてはできますが、データラベルではできません。R ggplot2でデフォルトのgeom_textの色を設定する方法は?
# Example of how to set default color for other text elements
library(ggplot2)
theme_set(theme_bw() + theme(text = element_text(color = "red"),
axis.text = element_text(color = "red")))
ggplot(mtcars, aes(x = cyl, label = ..count..)) +
geom_bar() +
geom_text(stat = "count") +
labs(title = "title")
可能な解決策は、http://ggplot2.tidyverse.org/reference/update_defaults.htmlにあります。 'update_geom_defaults(" text "、list(color =" red ")); ggplot(mtcars、aes(mpg、wt))+ geom_text(label = hp) ' – bdemarest
@bdemarestポストは答えですか? – dww
@bdemarestこれは私が探している解決策です。回答として投稿する必要があります –