【发布时间】:2017-01-22 04:36:17
【问题描述】:
我在 R 的 plotly 包中发现了我认为是 ggplotly 函数的怪癖。
当尝试在ggplotly 函数内包装ggplot 图(带有geom_bar 和stat = identity)时,负值被强制转换为正值。
以下是一个玩具示例:
library(ggplot2)
library(plotly)
set.seed(12345)
x <- data.frame(
x = 1:10,
obs = floor(rnorm(10) * 100)
)
# x obs
# 1 58
# 2 70
# 3 -11
# 4 -46
# 5 60
# 6 -182
# 7 63
# 8 -28
# 9 -29
# 10 -92
test_plot <- ggplot(x, aes(factor(x), obs)) + geom_bar(stat = "identity")
test_plot
ggplotly(test_plot)
使用其他geoms 时,这些值似乎不会被强制转换。我错过了什么吗?
感谢您的帮助。
【问题讨论】: