0
범례에서 레이블을 변경하고 싶습니다.ggplot2 범례의 레이블 변경
spi<-read.csv("spill.csv",as.is=TRUE)
attach(spi)
spi$date<-as.Date(spi$date)
str(spi)
data.frame: 3184 obs. of 3 variables:
$ data1: chr "oil to asset" "oil to asset" "oil to asset" "oil to asset" ...
$ date : Date, format: "2007-01-10" "2007-01-11" ...
$ sp : num 7.7 7.95 7.54 7.61 7.67 ...
cont1 <- ggplot(spi,aes(x=date,y=sp,linetype=data1))+geom_line() +
expand_limits(max(spi$sp), y=c(0,80)) +
labs(x = "", y = "") +
scale_y_continuous(breaks=seq(0,80,10)) +
scale_linetype_manual(values = c("dashed","solid")) +
scale_x_date(breaks=datebreaks1, labels=date_format("%Y")) +
ggtitle("Oil and Fianacial Market") +
annotate("rect", xmin=as.Date("2008-01-02"), xmax=as.Date("2008-06-30"),
ymin=-Inf, ymax=Inf, alpha=.1, fill="blue") +
theme(legend.position="bottom") + labs(linetype='')
그런 다음 자산을 석유 및 석유로 변경하려고합니다.
내가 어떻게 할 수 있습니까?
scale_fill_discrete(labels=c("oil to asset" ,"asset to oil"))
이
가 작동하지 않습니다.도와주세요.
'linetype' 범례의 라벨을 바꾸려고하십니까? '채우기'척도가 아닌'scale_linetype_manual' 또는'scale_linetype_discrete'와 같은'linetype' 척도로 할 필요가 있습니다. – aosmith
완전히 재현 할 수있는 예제를 첨부하면 도움이 될 때가 더 쉽습니다. 임의의 데이터 또는 실제 데이터에 대한 링크 포함. –