当我绘制facet_wrap()并将下划线放到x轴时,它们只会在第一个面上出现。我做错了什么或者这是一个错误吗? MWE:
library(plotly)
library(ggplot2)
gg<-ggplot(data = iris,
aes(x = Sepal.Length,
y = Sepal.Width,
color = Species,
group = Petal.Width,
text=sprintf("Petal Width %s<br>Sepal Length: %s", Petal.Width, Sepal.Length)
))+
geom_point()+
facet_wrap(~Species)
ggplotly(gg,tooltip = "text")%>%
layout(xaxis = list(showspikes = T))
答案 0 :(得分:0)
我认为你必须分享x或y轴。所以你可以试试:
gg<-ggplot(data = iris,
aes(x = Sepal.Length,
y = Sepal.Width,
color = Species,
group = Petal.Width,
text=sprintf("Petal Width %s<br>Sepal Length: %s", Petal.Width, Sepal.Length)
))+
geom_point()+
facet_grid(Species~.)
ggplotly(gg,tooltip = "text")%>%
layout(xaxis = list(showspikes = T))
或
gg<-ggplot(data = iris,
aes(x = Sepal.Length,
y = Sepal.Width,
color = Species,
group = Petal.Width,
text=sprintf("Petal Width %s<br>Sepal Length: %s", Petal.Width, Sepal.Length)
))+
geom_point()+
facet_wrap(~Species)
ggplotly(gg,tooltip = "text")%>%
layout(yaxis = list(showspikes = T))