我环顾四周,但我似乎无法找到解决方案。我在ggplot2中使用了geom_point和geom_hline,并且都获得了令人满意的传说。然而,我在图中有一条黑线和一条蓝线,但在图例中它们都是黑色的 - 我怎样才能在传说中纠正这种错误是正确的颜色?geom_hline的颜色在图例中不正确[ggplot2]
mcgc <- ggplot(sam, aes(x = Person,y = mm, colour = X)) +
geom_point(size = 0.75) +
scale_colour_gradient2(high="red", mid="green", limits=c(0,1), guide = "colourbar") +
geom_hline(aes(yintercept = mad, linetype = "mad"), colour = "blue", size=0.75, show_guide = TRUE) +
geom_hline(aes(yintercept = mmad, linetype = "mmad"), colour = "black", size=0.75, show_guide = TRUE) +
facet_wrap(~ Plan, scales = "free", ncol = 4) +
scale_linetype_manual(name = "Plan of Health Care", values = c("mad" = 1, "mmad" = 1),guide = "legend")
我敢肯定,我已经在这里写东西......只是不知道在哪里(是新来ggplot)
数据:
Plan Person X mm mad mmad
1 1 95 0.323000 0.400303 0.12
1 2 275 0.341818 0.400303 0.12
1 3 2 0.618000 0.400303 0.12
1 4 75 0.320000 0.400303 0.12
1 5 13 0.399000 0.400303 0.12
1 6 20 0.400000 0.400303 0.12
2 1 219 0.393000 0.353350 0.45
2 2 50 0.060000 0.353350 0.45
2 3 213 0.390000 0.353350 0.45
2 4 204 0.496100 0.353350 0.45
2 5 19 0.393000 0.353350 0.45
2 6 201 0.388000 0.353350 0.45
计划上升到40,但我只包含一小段数据...
更新:对于那些可能有所帮助 - 我的代码来绘制数据是错误的。我已经更新了这个。
你更可能通过编辑的问题,以获得帮助,如果你做这个重复的例子,包括您的数据(例如,'sam',和值'mad'和' mmad')。 – jlhoward
更新我的问题以包含数据。 – user2726449