我在将plotly::ggplotly
(v4.7.1)与facet_wrap
(v3.0.0)结合使用时遇到问题,我似乎无法一概而论,但是可以使用特定的数据集(一组数据集的摘要指标)进行重现的推文):
require(tidyverse)
require(plotly)
d = read_csv('https://gist.githubusercontent.com/geotheory/21c4eacbf38ed397f7cf984f8d92e931/raw/9148df79326f53a66a8cc363241a440752487357/data.csv')
d = d %>% mutate(key = fct_reorder(key, n)) # order the bars
p = ggplot(d, aes(key, n)) + geom_bar(stat='identity') +
facet_wrap(~ set, scales='free', nrow=1) +
labs(x=NULL, y=NULL) + coord_flip()
print(p)
输入ggplotly:
print(ggplotly(p))
这似乎与nrow=1
和scales='free'
参数的组合有关。关于原因有什么想法吗?