使用ggplotly生成一个plotly对象正好返回我需要的东西,但是,当使用api_create()并将对象推送到在线图形时,x轴显示为数字,而不是因为我声明它在R中。
mem$Office <- as.factor(mem$Office)
mem_plot <- ggplot(data=mem,aes(x=Office,y=Total, fill=Office)) +
geom_bar(size=mem$Total,width=0.5,position='dodge',stat='identity') +
labs(x = 'Office', y = 'Total')
mem_plot <- ggplotly(mem_plot,tooltip=c("x","y"))
mem_plot
然后我跑:api_create(mem_plot, filename = "memership-plot")
需要调整ggplotly()命令。
mem_plot <- ggplotly(mem_plot, dynamicTicks = T)