このグラフで凡例のタイトルをこのデータで変更することはできません。 ggplot2:凡例のタイトルを変更できません
df <- structure(list(year = structure(c(1L, 1L, 2L, 2L, 2L, 3L, 3L,
3L), .Label = c("2015", "2016", "2017"), class = "factor"), Category2 = c("grower",
"starter", "grower", "layer", "starter", "grower", "layer", "starter"
), per_pound = c(0.2072, 0.382, 0.172, 0.173, 0.3705, 0.178667,
0.1736, 0.277375)), .Names = c("year", "Category2", "per_pound"
), row.names = c(NA, -8L), vars = "year", drop = TRUE, class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
そして、私が作成していグラフ
...これを得ているlibrary (ggplot2)
p <- ggplot (data=df, aes(x=year, y=per_pound, group=Category2, color=Category2)) + geom_line() + geom_point()
p <- p + scale_fill_discrete(name="TEST")
p
...
伝説の名が 'TEST' ではない "でなければなりませんカテゴリ2 '。データフレーム内のデータに何か問題があるはずですが、私は原因を見つけませんでした。
-cherrytree
'P + scale_color_discrete(名= "TEST")を使用して凡例のタイトルを変更することができ' ggplot2'色 'において – www
はcolor''介しとにラインに割り当てられています'fill'を介した塗りつぶし領域 – Mako212