[英]Polar chart with R plotly package missing points
我有一个数据集,其中包含来自4个不同组的值。 我可以将所有值plotly
为具有正常笛卡尔坐标的散点图。 但是,当我为极坐标绘制相同的图形时,每组仅显示1个值。
要复制,我的玩具数据集是
bing <- structure(list(name = c("A", "C", "C", "A", "A", "C", "A", "D",
"D", "A", "B", "B", "A", "C", "A", "D", "D", "B", "C", "B"),
prob = c(10162L, 6L, 1838L, 5296L, 419L, 9340L, 7981L, 7524L,
9657L, 13349L, 9159L, 20612L, 12619L, 6404L, 7364L, 15878L,
6903L, 9185L, 1478L, 2310L)), .Names = c("name", "prob"), row.names = c(NA,
20L), class = "data.frame")
我用plot_ly(bing, type="scatter",x=prob, y=name, mode="markers")
绘制了笛卡尔散点图plot_ly(bing, type="scatter",x=prob, y=name, mode="markers")
并得到了显示点的以下内容。
我使用带有plot_ly(bing, type="scatter",r=prob, t=name, mode="markers")
极坐标进行绘制,得到的只有四个点。
我怎样才能解决这个问题?
我不确定plot_ly()
接受字符串/因数作为其r
参数,但是以下内容对我plot_ly()
。 我基本上将字符串映射为数字,如下所示。
plot_ly(bing, type = "scatter",
r = as.numeric(as.factor(name)),
t = prob, mode = "markers",
color = name)
希望这有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.