ggplotly忽略geom_bar的“线型”美学

使用ggplot2 plotly::ggplotly时如何使geom_bar正确渲染/打印线型?

这是一个可繁殖的例子:

library(tidyverse)
library(plotly)

# this shows the problem
static_plot = ggplot(data = mtcars,aes(x = rownames(mtcars),y = mpg,linetype=as.character(cyl))) +
  geom_bar(stat = "identity",fill = NA,color = "black")
print(static_plot) # see that here we have different linetypes as expected

ggplotly(static_plot) # the lines are all the same i.e continuous!

来自print(static_plot)的输出,其预期线型为:

ggplotly忽略geom_bar的“线型”美学

来自ggplotly(static_plot)的输出;没有考虑线型美学

ggplotly忽略geom_bar的“线型”美学

# using a geom_line it works fine
static_plot2 = ggplot(data = mtcars,aes(x = disp,linetype=as.character(cyl))) +
  geom_line(color = "black")
print(static_plot2)

ggplotly(static_plot2)

ggplotly忽略geom_bar的“线型”美学

也许这很明显,但我找不到解决办法...

QQ5211982511 回答:ggplotly忽略geom_bar的“线型”美学

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3110522.html

大家都在问