を変更することはできません。線種は、私は一例として、以下のデータをプロットを作成したいelement_line
library(data.table)
library(ggplot2)
library(plotly)
Data <- data.table(Datum = c("2017-11-01","2017-11-02","2017-11-03","2017-11-04","2017-11-05","2017-11-06","2017-11-07","2017-11-08","2017-11-09","2017-11-10"),Index = c(200,250,230,210,190,215,216,250,260,245), Long = c(c(250,220,225,215,240,255,256,266,223,222)))
Data$Datum <- as.Date(Data$Datum, format = "%Y-%m-%d")
startdate <- min(Data$Datum)
enddate <- max(Data$Datum)
plot <- ggplot(Data, aes(Datum)) +
geom_line(aes(y = Index, colour = "Index"), size = 0.5, alpha = 0.5) +
geom_line(aes(y = Long, colour = "Long"), size = 0.5, alpha = 0.5) +
theme(panel.background = element_rect(fill = "white")) +
theme(panel.grid.major.x = element_blank(), panel.grid.major.y = element_line(size = 0.5, colour = "grey", linetype = "dotted")) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
scale_y_continuous(breaks=seq(0,300,20)) +
scale_x_date(breaks = seq(as.Date(startdate), as.Date(enddate), by="2 month"), date_labels = "%m %Y") +
ylab("") +
xlab("")
plot <- ggplotly(plot)
print(plot)
しかし、あなたは、グラフでXグリッドの線種を見ることができるようにlinetype = "dotted"
私のアプローチでは、線種を変更するにはどうすればよいですか?
試してみてください – missuse
うん、ちょっとプロットパッケージ(またはplot.ly自体?)は、私がソースを読み込んだときに線種を変更する能力がないようです...:https://github.com/ropensci/plotly /blob/f5dd6ae20d0e266f456777828349b76f0b19ab81/R/ggplotly.R#L7 03-L706たぶんあなたはレポに問題を提出するべきです。 – yutannihilation
これはいくつかの回避策を提供します:http://sape.inf.usi.ch/quick-reference/ggplot2/linetype – seeellayewhy