r - unable changing linetype ggplot2 -
i change color
, line type in ggplot
. using code:
<- runif(84, 20, 80) a<-ts(a,start = 2009,frequency = 12) #a<-ts(result$`dataset1$summe`,start = 2009,frequency = 12) a3 <- zoo(a, order.by = as.date(yearmon(index(a)))) p1 <- autoplot(a3) p1 + scale_x_date(labels = date_format("%m/%y"),breaks = date_breaks("2 months"), limits = as.date(c('2009-01-01','2017-08-01')))+ theme(axis.text.x = element_text(angle = 90))+ theme(axis.text.x = element_text(angle = 90))+ labs(x = "date",y="test") + theme(panel.background = element_rect(fill = 'white', colour = 'black'))+geom_line(linetype="dotted", color="red")
but color changed. should change line type?
autoplot()
pick sensible default object it's passed. if want customize appearance it's better use standard ggplot()
function.
able zoo
object should passed trough fortify()
:
ggplot(fortify(a3, melt = true)) + geom_line(aes(x = index, y = value), linetype='dashed', color="red") + scale_x_date(labels = date_format("%m/%y"), breaks = date_breaks("2 months"), limits = as.date(c('2009-01-01','2017-08-01')))+ theme(axis.text.x = element_text(angle = 90), axis.text.x = element_text(angle = 90), panel.background = element_rect(fill = 'white', colour = 'black'))+ labs(x = "date",y="test")
(nb: dashed line @ top caused panel.background
theme option)
Comments
Post a Comment