在绘图 R 中映射标记大小时发出虚假警告 [英] spurious warning when mapping marker size in plotly R
问题描述
简单散点图具有映射到标记/点大小的第三个变量.情节对我来说看起来很完美,但它会发出有关多个值的警告.每个 x &y 值只有一个 size 值.
除了抑制警告之外,是否可以重新指定此图使其不抛出警告?
<块引用>警告信息:`line.width` 目前不支持多个值.
代码:
plotly::plot_ly(数据 = 虹膜,x = ~Sepal.Length,y = ~Petal.Length,大小 = ~Sepal.Width,类型 = '分散',模式 = '标记')
图表:
注意:这可能与 Plotly R - 错误`line.width` 当前不支持多个值." 或 Scatter mapbox in Shiny R 不会渲染,但是那些问题有很多动人的部分,所以我不知道这是不是他们的核心问题.em>
我已经在 https://github.com 上发布了这个问题/ropensci/plotly/issues/1367
我也遇到了同样的问题.查看 plotly github 页面,如下所示:https://www.reddit.com/r/RStudio/comments/9xq4gv/plotly_api_error_client_error_400_bad_request/,并搜索错误,让我找到了产生它的代码:
#如果填充不存在,`size`控制line.widthif (!has_fill(trace) && has_attr(type, line")) {s <- if (isSingular) size_ else if (array_ok(attrs$line$width)) 大小 else NA如果 (is.na(s)) {警告(`line.width` 目前不支持多个值.",调用.=错误的)} 别的 {trace[[line"]] <- modify_list(list(width = default(s)), trace[[line"]])}}
参数填充默认为无".将此设置为空字符串,并在标记中设置 sizemode = ~diameter
对我有用:
plotly::plot_ly(数据 = 虹膜,x = ~Sepal.Length,y = ~Petal.Length,类型 = '分散',模式 = '标记',大小 = ~Sepal.Width,填充 = ~'',标记 = 列表(大小模式 = '直径'))
The simple scatterplot has a third variable mapped to the marker/point size. The plot looks perfect to me, but it throws a warning about multiple values. Each x & y value has exactly one size value.
Other than suppressing the warning, can a respecify this graph so it does not throw the warning?
Warning message: `line.width` does not currently support multiple values.
Code:
plotly::plot_ly(
data = iris,
x = ~Sepal.Length,
y = ~Petal.Length,
size = ~Sepal.Width,
type = 'scatter',
mode = 'markers'
)
Graph:
Note: This may be related to Plotly R - error "`line.width` does not currently support multiple values." or Scatter mapbox in shiny R will not render, but those questions have a lot more moving pieces, so I don't know if this is their core problem.
edit: I've since posted this question at https://github.com/ropensci/plotly/issues/1367
I had the same issue as well. Looking in the plotly github page, as suggested here: https://www.reddit.com/r/RStudio/comments/9xq4gv/plotly_api_error_client_error_400_bad_request/, and searching for the error, led me to the code that produces it:
# 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"]])
}
}
The parameter fill defaults to "none". Setting this to an empty string, and setting sizemode = ~diameter
in marker worked for me:
plotly::plot_ly(
data = iris,
x = ~Sepal.Length,
y = ~Petal.Length,
type = 'scatter',
mode = 'markers',
size = ~Sepal.Width,
fill = ~'',
marker = list(sizemode = 'diameter'))
这篇关于在绘图 R 中映射标记大小时发出虚假警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!