R ggplotly产生正确的图,但是当移动到plot.ly时,x轴是不同的

问题描述 投票:0回答:1

使用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 

返回:enter image description here

然后我跑:api_create(mem_plot, filename = "memership-plot")

从plot.ly得到这个:enter image description here

r plotly ggplotly
1个回答
0
投票

需要调整ggplotly()命令。

mem_plot <- ggplotly(mem_plot, dynamicTicks = T)
© www.soinside.com 2019 - 2024. All rights reserved.