error_x ignores user provided value; defaults to 10 always
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Using the example for coef plots here, I find that no matter what values are provided o error_x = ~ ... , the plot always shows error bars at 10% of the point-estimate.
Brief description of the problem
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
library(ggplot2)
fit <- lm(mpg ~ cyl + disp + wt, mtcars)
summary(fit)
#>
#> Call:
#> lm(formula = mpg ~ cyl + disp + wt, data = mtcars)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -4.4035 -1.4028 -0.4955 1.3387 6.0722
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 41.107678 2.842426 14.462 1.62e-14 ***
#> cyl -1.784944 0.607110 -2.940 0.00651 **
#> disp 0.007473 0.011845 0.631 0.53322
#> wt -3.635677 1.040138 -3.495 0.00160 **
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 2.595 on 28 degrees of freedom
#> Multiple R-squared: 0.8326, Adjusted R-squared: 0.8147
#> F-statistic: 46.42 on 3 and 28 DF, p-value: 5.399e-11
# Plots Don't Agree. Plotly shows incoprrect error bars
goodplot <- GGally::ggcoef(fit, sort = "ascending")
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
badplot <- fit %>% broom::tidy() %>%
mutate(term = forcats::fct_reorder(term, estimate)) %>%
plot_ly(x = ~ estimate, y = ~ term) %>%
add_markers(
error_x = ~ list(value = std.error),
color = I("black"),
hoverinfo = "x"
)
Created on 2020-03-02 by the reprex package (v0.3.0)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 reprex 的 add_markers() 调用及其 error_x = ~ list(value = std.error) 映射开始,然后跟踪 R 接口如何处理用户提供的误差条值。使用 mtcars 模型重现该图,并确认显示的是所提供的标准误,而不是默认的 10% 值。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- plotly, r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100