繁体   English   中英

在绘图 R 中映射标记大小时发出虚假警告

[英]spurious warning when mapping marker size in plotly R

简单散点图具有映射到标记/点大小的第三个变量。 情节对我来说看起来很完美,但它会发出有关多个值的警告。 每个x & y值都有一个大小值。

除了抑制警告之外,是否可以重新指定此图以使其不引发警告?

 Warning message: `line.width` does not currently support multiple values.

代码:

plotly::plot_ly(
  data  = iris, 
  x     = ~Sepal.Length, 
  y     = ~Petal.Length, 
  size  = ~Sepal.Width,
  type  = 'scatter', 
  mode  = 'markers'
)

图形: 散点图

注意:这可能与Plotly R相关- 错误“`line.width` 当前不支持多个值。” 或者Scatter mapbox 在闪亮的 R 中不会渲染,但是这些问题有更多动人的部分,所以我不知道这是否是他们的核心问题。

编辑:我已经在https://github.com/ropensci/plotly/issues/1367发布了这个问题

我主要在 Python 中使用 Plotly,所以我不确定细节,但大小是 Plotly 中许多事物的属性。 我猜测通过在该级别设置size = ~Sepal.Width库无法知道您要设置标记大小。

plotly::plot_ly(
    data   = iris, 
    x      = ~Sepal.Length, 
    y      = ~Petal.Length,
    type   = 'scatter', 
    mode   = 'markers',
    marker = list(
        size = ~Sepal.Width*3
    )
)

这对我有用,出于某种原因,点变得更小了,但缩放它们效果很好。

我也有同样的问题。 查看 plotly github 页面,如下所示: https ://www.reddit.com/r/RStudio/comments/9xq4gv/plotly_api_error_client_error_400_bad_request/ 并搜索错误,使我找到了生成它的代码:

# if fill does not exist, `size` controls line.width
      if (!has_fill(trace) && has_attr(type, "line")) {
        s <- if (isSingular) size_ else if (array_ok(attrs$line$width)) sizes else NA
        if (is.na(s)) {
          warning("`line.width` does not currently support multiple values.", call. = 
    FALSE)
        } else {
          trace[["line"]] <- modify_list(list(width = default(s)), trace[["line"]])
        }
      }

参数填充默认为“无”。 将此设置为空字符串,并设置
标记中的sizemode = ~diameter对我sizemode = ~diameter

plotly::plot_ly(
data   = iris, 
x      = ~Sepal.Length, 
y      = ~Petal.Length,
type   = 'scatter', 
mode   = 'markers',
size = ~Sepal.Width,
fill = ~'',
marker = list(sizemode = 'diameter'))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM