我在ggplotly中使用了一个geom_bar绘图图形,并将负向条形图呈现为正数。任何想法为什么这可能是这种情况,特别是如何解决这个问题?ggplotly在正方向上绘制负向条形图
library(ggplot2)
library(plotly)
dat1 <- data.frame(
sex = factor(c("Female","Female","Male","Male")),
time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(-13.53, 16.81, 16.24, 17.42)
)
# Bar graph, time on x-axis, color fill grouped by sex -- use position_dodge()
g <- ggplot(data=dat1, aes(x=time, y=total_bill, fill=sex)) +
geom_bar(stat="identity", position=position_dodge())
ggplotly(g)
为什么第一个柱子会处于正向,负值?
,我使用的版本是最新的:
plotly_3.4.13
ggplot2_2.1.0
看起来像这是一个'ggplotly'的已知问题(https://github.com/ropensci/plotly/issues/560) – joemienko
啊我看到了...那是不幸的。有关避免这个问题的任何建议,而不是打开阴谋(例如通过更改某些规范)?或者最好等待修复? – Nick
我认为这取决于您的具体使用情况 - 您确定需要积极使用吗? – joemienko