n value name
1 20 1
2 30 1
3 25 1
1 40 2
2 12 2
3 39 2
이것이 내가 지금 플롯하는 방법입니다.
require(ggplot2)
data <- read.table("test", sep = "\t", header = TRUE,)
ggplot(data, aes(n, value,color=as.character(name))) +
geom_point(aes(n,value)) + geom_line(aes(n,value))
dev.off()
"as.character (name)"를 "New Title"로 변경하고 "1"및 "2"값을 "value1"및 "value2"로 변경하고 싶습니다.
다음을 시도했지만 작동하지 않았습니다.
require(ggplot2)
data <- read.table("test", sep = "\t", header = TRUE,)
ggplot(data, aes(n, value,color=as.character(name))) + geom_point(aes(n,value))
+ geom_line(aes(n,value)) +
scale_fill_manual(name="My title", values=c("value1", "value2"))
dev.off()
당신은 필요 scale_color_manual
하지 않습니다 scale_fill_manual
. 그런 다음 values
제공해야하는 색상 값을 참조하고 세 번째 매개 변수는 labels
입니다.
+ scale_color_manual(name = "New Title",
labels = c("value1", "value2"),
values = c("red", "green"))
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다